ew class named “Student” that must inherit from the given User class. This class manages student info: id (integer), name (string) and gpa (double). It must prevent the creation of a Student object with a negative ID or a GPA that is not between th
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
in c++
Define a new class named “Student” that must inherit from the given User class.
This class manages student info: id (integer), name (string) and gpa (double).
It must prevent the creation of a Student object with a negative ID or a GPA that
is not between the range of 0.0 and 4.0 by generating a BadValueException error.
This class will provide at least the following methods:
toString method to return a string representation of the Student object in the
format of “ID( <id> ) NAME( <name> ) GPA( <gpa> )”
Such as
ID(1234) NAME(John Smith) GPA(4.00)
Note: the GPA must have 2 decimal places.
isGPAGreater method that compares its gpa with another student’s gpa. It
returns true if its gpa is greater than the other and false otherwise.
Step by step
Solved in 4 steps with 2 images