I am in need of a hand if anyone has time to have a look
(a) Develop a class called Module that describes a module at a university. The Module class has instance variables as follows:
The Module class will require the following methods, which other classes should be able to access.
- code is a reference to the code of the module, a String e.g. a valid code would be "P101"
- title is a reference to the title of the module, a String e.g. "Feeding fish"
- points stores the number of points the module is worth, an int.
Also add the following constructor to the Module class:
- Standard getter and setter methods for the instance data (code, title and points); that is, the getters return the instance data values and the setters set the instance data values to received arguments.
- String toString returns a string containing the full details of the module, giving the module code, title and number of points in parentheses, for example P101, Doing Neat Stuff (20 points).
- boolean equals(Object o) returns true if the module referenced by o has the same instance variable values as the object on which this method is invoked; otherwise the method returns false. (Note, you do not have to worry about the case when the string instance data is null.)
- boolean isCode(String aCode) returns true if the aCode string is a valid module code. For this scenario this means that it begins with a capital letter and has exactly four characters. Otherwise the method returns false. This method is a class method, not an instance method.
- a three-argument constructor receiving a code, a title string, and a number of points, which sets the code, title and points data of the created object to the received values.
I have developed my class called module and inputted my setter and getter methods, it is the toString and Boolean one i am having difficulty with.
I have inputted
public String toString ()
return "Module" + myCode + "Points" + myPoints;
}
Module o = new myCode ("example");
System.out.println (o);
}
Seem to get the enum / class interface expected error?
many thanks
Social Networking Bookmarks