Entertainer
04-25-2005, 04:59 AM
Alright, there seems to be an error, but i just have no idea what it could be or how i could solve it.
Could you guys look at it and maybe tell me where the error is? i'm getting a little bit annoyed by this ******* bull.
import java.awt.event.*;
import java.lang.Integer;
/*
* Created on 21-mrt-2005
* @author R. Knijntje
*
*
*
*
* Created by R. Knijnenburg
* Copyright @ R. Knijnenburg
*/
public class RekenMachineLuisteraar implements ActionListener
{
private RekenMachineModel m;
private RekenMachineView v;
private RekenMachineValidator rV;
public class RekenMachineValidator
{
private boolean correctheid;
private int foutNummer;
public String bericht;
public boolean getCorrectheid()
{
return (correctheid);
}
public String foutcodeToFoutmelding(int foutNummer)
{
String bericht = "";
switch(foutNummer)
{
case 0:
bericht = "Alles is goed ingevoerd";
case 1:
bericht = "Er kunnen niet meer dan 9 cijfers verwerkt worden";
case 2:
bericht = "Er is niets ingevuld in 1 van de velden";
case 3:
bericht = "Er mogen alleen getallen ingevuld worden";
default:
bericht = "Fout bij het controleren";
}
return(bericht);
}
public RekenMachineValidator()
{
foutNummer = 0;
correctheid = true;
}
public int checkFout(String checkString)
{
char tempChar;
correctheid = true;
foutNummer = 0;
if (checkString.length() > 9)
{
foutNummer = 1;
correctheid = false;
}
else if (checkString == "")
{
foutNummer = 2;
correctheid = false;
}
else
{
for (int i = 0; i < checkString.length(); i++)
{
tempChar = checkString.charAt(i);
if (!Character.isDigit(tempChar))
{
foutNummer = 3;
correctheid = false;
}
}
}
return foutNummer;
}
}
public RekenMachineLuisteraar(RekenMachineModel m , RekenMachineView v)
{
rV = new RekenMachineValidator();
this.m = m;
this.v = v;
}
public void actionPerformed(ActionEvent arg0)
{
String stringGetal1 = v.geefInvoer1();
String stringGetal2 = v.geefInvoer2();
System.out.println(v.geefInvoer1());
System.out.println(v.geefInvoer2());
int intGetal1;
int intGetal2;
intGetal1 = Integer.parseInt(stringGetal1);
intGetal2 = Integer.parseInt(stringGetal2);
m.setGetal1(intGetal1);
m.setGetal2(intGetal2);
if(rV.correctheid = false)
{
v.setUitkomst(rV.foutcodeToFoutmelding(1));
}
else
{
v.toonResultaat(m.geefOptelling());
}
}
}
Could you guys look at it and maybe tell me where the error is? i'm getting a little bit annoyed by this ******* bull.
import java.awt.event.*;
import java.lang.Integer;
/*
* Created on 21-mrt-2005
* @author R. Knijntje
*
*
*
*
* Created by R. Knijnenburg
* Copyright @ R. Knijnenburg
*/
public class RekenMachineLuisteraar implements ActionListener
{
private RekenMachineModel m;
private RekenMachineView v;
private RekenMachineValidator rV;
public class RekenMachineValidator
{
private boolean correctheid;
private int foutNummer;
public String bericht;
public boolean getCorrectheid()
{
return (correctheid);
}
public String foutcodeToFoutmelding(int foutNummer)
{
String bericht = "";
switch(foutNummer)
{
case 0:
bericht = "Alles is goed ingevoerd";
case 1:
bericht = "Er kunnen niet meer dan 9 cijfers verwerkt worden";
case 2:
bericht = "Er is niets ingevuld in 1 van de velden";
case 3:
bericht = "Er mogen alleen getallen ingevuld worden";
default:
bericht = "Fout bij het controleren";
}
return(bericht);
}
public RekenMachineValidator()
{
foutNummer = 0;
correctheid = true;
}
public int checkFout(String checkString)
{
char tempChar;
correctheid = true;
foutNummer = 0;
if (checkString.length() > 9)
{
foutNummer = 1;
correctheid = false;
}
else if (checkString == "")
{
foutNummer = 2;
correctheid = false;
}
else
{
for (int i = 0; i < checkString.length(); i++)
{
tempChar = checkString.charAt(i);
if (!Character.isDigit(tempChar))
{
foutNummer = 3;
correctheid = false;
}
}
}
return foutNummer;
}
}
public RekenMachineLuisteraar(RekenMachineModel m , RekenMachineView v)
{
rV = new RekenMachineValidator();
this.m = m;
this.v = v;
}
public void actionPerformed(ActionEvent arg0)
{
String stringGetal1 = v.geefInvoer1();
String stringGetal2 = v.geefInvoer2();
System.out.println(v.geefInvoer1());
System.out.println(v.geefInvoer2());
int intGetal1;
int intGetal2;
intGetal1 = Integer.parseInt(stringGetal1);
intGetal2 = Integer.parseInt(stringGetal2);
m.setGetal1(intGetal1);
m.setGetal2(intGetal2);
if(rV.correctheid = false)
{
v.setUitkomst(rV.foutcodeToFoutmelding(1));
}
else
{
v.toonResultaat(m.geefOptelling());
}
}
}