|
Java Assistance with a slotmachine.
Hello, I could use some help with a slotmachine assignment I have gotten majority of the first class which is TripleString. I'm having trouble with the accessor string and the mutator string. Well I added String in front of the set string which is str1=s1; str2=s2; etc. Is this right? Eclpise is telling me with the accessor string to add a return getstr1(); instead of return str1();. Which one of all these things are right? Sorry if I sound a bit confusing I am a bit overwhelmed right now.
import java.util.*;
public class slotmachine{
static Scanner input = new Scanner(System.in);
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
class TripleString {
public static final int MAX_LEN = 20;
private String string1;
private String string2;
private String string3;
TripleString()
{
string1 ="";
string2 ="";
string3 ="";
}
public void setTripleString (String str1, String str2, String str3) {
string1 = str1;
string2 = str2;
string3 = str3;
}
public void setStrings(String s1, String s2, String s3){
String str1 = s1; String str2 = s2; String str3 = s3;
}
public String getstr1(){
return str1();
}
public String getStr2(){
return str2();
}
public String getstr3(){
return str3();
}
private boolean vaildString( String str ) {
if (str.length() >0 && str.length() <= MAX_LEN) {
return true;
}
else {
return false;
}
}
}
|