Question: Use Java to create two classes for tracking students. One class is the Student class that holds student data; the other is the GradeItem class
Use Java to create two classes for tracking students. One class is the Student class that holds student data; the other is the GradeItem class that holds data about grades that students earned in various courses.
Problem Scenario
CU Boulder needs a Java programmer to assist them with creating a grade book application. You have graciously volunteered to help. The university wants to track their students and their grades in various courses. For each student, the university wants to track this information:
1. Student id (String a unique value for each student)
2. Student first name (String)
3. Student last name (String)
4. Student email address (String a unique value for each student)
The university wants to make sure that they have a correct email address for each student. They want you to verify there is an @ in the email address.
For each grade item, the university wants to track this information:
1.Grade Item id (Integer a unique value for each grade item)
2.Student id (String should match a student in the student list)
3.Course id (String)
4.Item type (String must be one of the following: HW, Quiz, Class Work, Test, Final)
5.Date (String format yyyymmdd)
6.Maximum score (Integer must be greater than 0)
7.Actual score (Integer must be in the range of 0 to maximum score)
Program Requirements
You have to create two classes for the problem scenario given above. The classes are:
A Student class
A Grade Item class
These two classes will be used in subsequent projects to instantiate the Student and Grade Item objects, and will not contain a main method or any I/O code. Your Student and Grade Item classes should each contain these methods:
Constructor
Get methods for each private variable
A toString method to display an instance of an object
An equals method to determine whether two instances of an object contain exactly the same data
Note: We will assume that our objects are immutable (unchanged once an object is instantiated) so we dont need any set methods.
Constructors in each class should validate the data as follows:
In the Student class
Ensure all values for String fields are not blank. These are the student id, first name, last name and email address.
Ensure the student email address contains the @ character. Hint: Use the contains method in the String class.
In the Grade Item class
Ensure all values for String fields are not blank. These are the student id, course id, item type and date.
All Grade item types must be one of the following: HW, Quiz, Class Work, Test, or Final. Use an array to store the types and search that array for a valid type. The entries are casesensitive (HW does not equal Hw).
Grade Item class: Maximum score must be greater than 0.
Grade Item class: Actual score must be in the range of 0 to maximum score.
If any of the data in either class is invalid, the constructor in which the error was detected must throw the IllegalArgumentException exception.
Note: Data required to initialize the fields will be passed by a method (defined in a subsequent project) to the constructor using arguments. Do not display any error messages or use the Scanner class to ask user for input.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
