This is the requirements for the Student class I have to create. I created all of it to what I think is right by i am running it to some problems in storing and in my setNames(iNames); setMajors(iMajors); setCredits(iCredits); Any help or suggestions in stuff that I missed or that does not look right. The Student class Within the App.java source file and after the closing brace of the App class, define an instantiable Student class. The class must contain: �Instance variables for holding the student's name (a String), major (a StringBuffer), and credits earned (an int). All instance variables must be declared private. �A public class constant named SENIOR with an int value of 90. This will be used to determine whether a student is a senior. �A single constructor that accepts values for all three instance variables. It should call the "set" methods (described below) to edit and store the initial values it receives. �Instance methods to "set" and "get" the value of each instance variable. Each "get" method should simply return the value of its corresponding variable. The "set" method that stores the student's name must receive a String and store it if it isn't empty. Nothing must be returned to the caller. The "set" method that stores the student's major must receive a StringBuffer and store it if the value of its string is "CIS", "MGT", "MKT", "ACT", or "none". Otherwise, nothing should be stored. The method must return a boolean to indicate whether the data it received was valid. The "set" method that stores the credits earned must receive an int and store it if the value is greater than or equal to zero. Otherwise, nothing should be stored. The method must return a boolean to indicate whether the data it received was valid. �An instance method named isSenior that accepts no parameters and returns a boolean that indicates if the student is a senior.
In most cases people don't call set methods from within their constructors. They just set the instance variable directly. In your case your set methods are a little more compilicated. And you don't check the booleans which are being returned. So, ... what is your problem?
Please ignore post, I have no idea what I am talking about.
Joined: Feb 11, 2003
At this line
i am getting this error 'class' or 'interface' expected at line 31 and at this line
and this error
Joined: Feb 11, 2003
Sorry the error is 'class' or 'interface' expected at line 51
First off you have 2 methods called setMajors, why confuse yourself that way?
I am going to run the risk of sounding like a nitpicker but methods starting with 'set' implies 'void'. Whereas 'has' or 'is' implies true or false? Whereas 'get' or 'do' or ... implies some other return? See �6.8.3 Method Names et seq. doco [ April 15, 2003: Message edited by: Donald R. Cossitt ]