Home > Back-end >  Question for help
Question for help

Time:05-18

1. To design a Student class, requirements are as follows:

1) the class inherits from the Person class, the Person class has a member variable name, gender, age, height, weight, and occupation, etc., 2) the Person class rewrite toSting, method to check the attributes of the object instance; Have elegantly-named setName method to revise the name: setAge method to modify age: have setlob method modified professional information,,

3) the Student class has a member variable Student id, elective course, GPA, grade, school, etc., hill

4) Student class override toString method to check the attributes of the object instance; SetGPA method modified grade point, setGrade method modified grade, have addCourse method for instance objects add optional courses, delete the instance objects have deleteCourse method selected courses, and

5) write a Test class Test, provide verify the following functions in the class of operation menu: you can create any number of Student object, can choose to modify the object instance name, modify age operation, set up the grade point operation, to the same college students sort by GPA, and output the sorted all the Student information (GPA rank), to register for a classmate to add a door, for a return to register a, classmate,

CodePudding user response:

1. Define the Person class, put properties of need, to automatically generate the get/set methods, rewrite the toString, which can use the IDE automatically generated
2. Define the Student class inheritance Person, combined with their own properties, as well as generate the get/set methods,
3. The Student new addCourse method, the ginseng is elective course, set this property is recommended, calling the API. The add (elective class name);
4. Student new deleteCourse method, the ginseng is elective course, call the API. Remove (elective class name);
5. The Test class created in the collection of Student
6. Traversal Student collection to make subsequent corresponding operation
  • Related