![]() |
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; } } } |
These three methods for str1() through 3, simply do not exist. I would presume the intent is to return string1 - string3. setStrings method also doesn't do anything useful, so you should either remove it or correct it.
Also, in the future please wrap your code in [php][/php] or [code][/code] tags to preserve formatting. |
ok, so do i create a method or each of the str1-3?
Quote:
|
I don't know why you'd want to. You already have getStr1 through 3, so simply return the property that its representing in there.
|
| All times are GMT +1. The time now is 06:01 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.