another question
can someone help me with what's wrong with my LottoTicket?
i tried to run it against the test, but got an error. i dont think it can find LottoTicket.
also, i didnt write the test :\
import java.util.*;
publicclass LottoTicket
{
private String let1;
private String let2;
private String let3;
private String let4;
private String let5;
private String thisticket;
privatestatic String lastticket;
publicvoid lastTicket(String s){
String thisticket = s;
String lastticket ="ZZZZZ";
}
publicvoid thisTicket(){
Random r =new Random();
int x1 = r.nextInt(27);
int x2 = r.nextInt(27);
int x3 = r.nextInt(27);
int x4 = r.nextInt(27);
int x5 = r.nextInt(27);
let1 = Integer.toString(x1);
let2 = Integer.toString(x2);
let3 = Integer.toString(x3);
let4 = Integer.toString(x4);
let5 = Integer.toString(x5);
lastticket ="ZZZZZ";
String ticket = let1+let2+let3+let4+let5;
thisticket = ticket.toUpperCase();
}
publicvoid generateNext(){
Random r =new Random();
int x1 = r.nextInt(27);
int x2 = r.nextInt(27);
int x3 = r.nextInt(27);
int x4 = r.nextInt(27);
int x5 = r.nextInt(27);
let1 = Integer.toString(x1);
let2 = Integer.toString(x2);
let3 = Integer.toString(x3);
let4 = Integer.toString(x4);
let5 = Integer.toString(x5);
lastticket = let1+let2+let3+let4+let5;
}
public String getThisTicket(){
return thisticket;
}
public String getLastTicket(){
return lastticket;
}
}
publicclass LottoTestextends junit.framework.TestCase
{
private LottoTicket lt;
publicvoid TestConstructor1(){
lt =new LottoTicket();
assertEquals("ZZZZZ", lt.getLastTicket());
assertFalse("ZZZZZ".equals(lt.getThisTicket()));
}
publicvoid testConstructor2(){
lt =new LottoTicket("AAAAA");
assertEquals("ZZZZZ", lt.getLastTicket());
assertEquals("AAAAA", lt.getThisTicket());
}
publicvoid testGenerateNext(){
lt =new LottoTicket();
lt.generateNext();
assertFalse("ZZZZZ".equals(lt.getLastTicket()));
}
publicvoid testStatic(){
lt =new LottoTicket();
LottoTicket lt2 =new LottoTicket();
lt.generateNext();
assertEquals(lt.getLastTicket(), lt2.getLastTicket());
}
}

