Use the StudentMark class given in this assignment, override the equals method to identify the equality of
Question:
Use the StudentMark class given in this assignment, override the equals method to identify the equality of both StudentMark objects in term of id and mark.
Write a class called Module to store a set of StudentMark objects (you can assume no more than 10 students). All objects should store in a one-dimensional array. Here is the class diagram of Module class:
Implement all the methods stated inside the Module class.
Default constructor: Initialise the array object
addStudentMark method: Add new student mark into the array list
printMarkList method: Print out the student id and mark in tabular format
getAverageMark method: Calculate and return the average mark
Write the driver/test class with the main method to allow input of student ids and marks. The id XXX should denote the end of the input. The main method should also print the list of ids and marks and the overall average mark on the screen using instance methods.
public class StudentMark {
private String id;
private int mark;
public StudentMark() {
this("",0);
}
public StudentMark(String id, int mark) {
this.id = id;
this.mark = mark;
}
public String getId() {return id;}
public int getMark() {return mark;}
public void setId(String id) {this.id = id;}
public void setMark(int mark) {
if (mark>=0)
this.mark = mark;
}
public String toString() {
return "[ID="+id + ", Mark=" + mark + "]";
}
//TASK: You have to override the equals method at here
}
Managerial Accounting A Focus on Ethical Decision Making
ISBN: 978-0324663853
5th edition
Authors: Steve Jackson, Roby Sawyers, Greg Jenkins