Question
Java and plz use student class and code tester thank you! /* * Student.java * * A Student class * */ public class Student {
Java and plz use student class and code tester thank you!
/* * Student.java * * A Student class * */ public class Student { private String sID; private int grade; public Student() { sID = ""; grade = -1; } public Student(String sID, int grade) { this.sID = sID; this.grade = grade; } /* Purpose: returns this Student's sID * * Parameters: none * * Returns: String - the sID * */ public String getSID() { return this.sID; } /* Purpose: set's this Student's sID to sID parameter value * * Parameters: String - sID * * Returns: nothing * */ public void setSID(String sID) { this.sID = sID; } /* * * Purpose: returns this Student's grade * * Parameters: none * * Returns: int - the sID * */ public int getGrade() { return this.grade; } /* * * Purpose: set's this Student's grade to grade parameter value * * Parameters: int - grade * * Returns: nothing * */ public void setGrade(int grade) { this.grade = grade; } /* * * Purpose: returns a String representation of this Student * in the form "sID:grade" * * Parameters: none * * Returns: String - the representation * */ public String toString() { return sID + ":" + grade; } /* * * Purpose: returns true if this Student's sID * equals other Student's sID * * Parameters: none * * Returns: boolean - true if equal, false otherwise * */ public boolean equals(Student other) { return (this.sID.equals(other.sID)); } } public static void testNode() { Student s0 = new Student("abc", 50); Student s1 = new Student("def", 56); Student s2 = new Student("xyz", 99); Student s2b = new Student("xyz", 29); StudentNode n0 = new StudentNode(s0); // must use == to determine whether they are the SAME object, // .equals will tell us if they are equivalent sIDs displayResults(n0.getData() == s0, "test contructor 1 arg with getData"); displayResults(n0.getNext() == null, "test contructor 1 arg with getNext"); StudentNode n1 = new StudentNode(s1, n0); displayResults(n1.getData() == s1, "test contructor 2 args with getData"); displayResults(n1.getNext() == n0, "test contructor 2 args with getNext"); StudentNode n2 = new StudentNode(s2, n1); displayResults(n2.getData() == s2, "test contructor 2 args with getData"); displayResults(n2.getNext() == n1, "test contructor 2 args with getNext"); displayResults(n2.getNext().getNext() == n0, "test contructor 2 args with getNext"); n2.setData(s2b); displayResults(n2.getData() == s2b, "test setData with getData"); n2.setData(s1); displayResults(n2.getData() == s1, "test setData with getData"); n2.setNext(n0); displayResults(n2.getNext() == n0, "test setNext with getNext"); displayResults(n2.getNext().getNext() == null, "test setNext with getNext"); }
* Purpose: removes the first element in the list * Parameters: none * Returns: nothing public void removeFront (); * Purpose: removes the first element in the list * Parameters: none * Returns: nothing public void removeFront ()Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started