I am trying to make the game ONE, I have 5 classes: Model, Window, Controller, Cards and ONE.
In the UNO class there is the main and there I have an object of type Controller that receives 2 attributes, v and m with v the name of the constructor of Window and m the name of the constructor of the Model.
the error marks me in the window class, where I try to initialize an attribute of type Controller, it asks me to put what it receives inside the parentheses ... (m, v) to do it gives error, that's why I created a variable of type Window in the class window and initialized it in the following way this.ve=v;
that makes the error that marks me Netbeans disappear, but when executing the code and giving the button in question the error jumps.
The code is as follows:
package uno;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
*
* @author juana
*/
public class Ventana extends JFrame{
JButton miButtoncrt;
JButton Uno,Robar;
int ncdj=0,ncdm=0;
Modelo mo;
Cartas[] mv;
Controlador c;
Ventana v;
JButton [] botonesm;
JButton [] botonesj;
Ventana(String uno, Modelo m) {
super(uno);
this.mo=m;
this.v=v;
mv = new Cartas[80];
for(int yo=0;yo<=79;yo++)
{
mv[yo] = new Cartas();
}
this.setLayout(null);
this.setSize(1366,768);
this.botonesm = new JButton[78];
this.botonesj = new JButton[78];
for(int i = 0; i<=77; i++)
{
botonesm[i] = new JButton();
botonesm[i].setBounds(80*i, 50, 80, 140);
botonesj[i] = new JButton();
botonesj[i].setBounds(80*i, 450, 80, 140);
}
miButtoncrt = new JButton();
miButtoncrt.setBounds(650, 220, 80, 140);
this.add(miButtoncrt);
Uno = new JButton();
Uno.setBounds(900, 265, 90, 60);
this.add(Uno);
Robar = new JButton();
Robar.setBounds(400, 265, 90, 60);
this.add(Robar);
c = new Controlador(m,v);
Robar.addActionListener(c);
for(int i=0;i<=79;i++)
{
if(mo.carta[i].getOwner()=="Jugador")
{
ncdj++;
}
if(mo.carta[i].getOwner()=="Máquina")
{
ncdm++;
}
}
for(int j=0;j<ncdj;j++)
{
this.add(botonesj[j]);
this.add(botonesm[j]);
}
this.setVisible(true);this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}