HW#2 (Classes)
HW#2 (Classes)
Student
Notes:
- id : String
- name : String - The first 2 methods are constructors.
- GPA : double - Set and get are well known methods.
+ Student (id) - isHigher (av: double) should compare the student
+ Student (id, name) GPA with an average, say 2.7 passed as a
+ setName (name: String) parameter. The method returns true if the student
+ setGPA (value: double) GPA is higher than the average, and false
+ getGPA( ): double otherwise.
+ getName ( ) : String - ToString override the inherited method to display
+ isHigher (av: double) : Boolean the fields of the objects (id, name and GPA) in
+ ToString ( ): String well formatted way.
-
b) Write the statement(s) needed for the following questions:
(total 5 marks)
a) Create two objects named (maleStudent) and (femaleStudent) using different constructors
with ant values you select.
(1 marks)
b) Set any name for the object created by the first constructor.
(0.5
mark)
g) Display the information (fields) of one of the objects explicitly and the other object
implicitly.
(1 marks)