Uploaded by tjdstrahan

Inheritance Practise

advertisement
Inheritance Practise
Create the following classes…
Student
- name : String
- studentNumber : int
- courseLevel : int
+ Student(String name, int num, int level)
+ getName() : String
+ setName(String) : void
+ getStudentNumber() : int
+ setStudentNumber(int) : void
+ getCourseLevel () : int
+ setCourseLevel (int) : void
+ outputDetails () : String
FdseStudent
- languageUsed : String
+ FdseStudent ( String name, int num, int level, String lang )
+ getLanguageUsed () : String
+ setLanguageUsed( String ):void
+ outputDetails () : String
CookeryStudent
- apprentice : boolean
+ CookeryStudent ( String name, int num, int level, String lang, boolean apprentice)
+ isApprentice() : boolean
+ setApprentice( boolean )
+ outputDetails () : String
See notes below:
The constructor for each derived class must call the constructor in the base
class to initialise the fields.
Override the outputDetails method in the base class to return information
about the specific type of student (FDSE or Cookery), also:
 Use the super keyword in the FdseStudent outputDetails
method, to call the outputDetails method in the parent class.
 In the CookeryStudent class, use the getter methods in
Student, in order to create the String returned by the
outputDetails method.
Write a test program to implement 3 objects, one of each class, and then
invoke each method belonging to the object to test its functionality.
Download