Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribed

/* * 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: returns a String reprensentation of the elements in this list separated by newlines * Parameters: none * Returns: String the representation public String toString(); * Purpose: returns a String reprensentation of the elements in this list separated by newlines * Parameters: none * Returns: String the representation public String toString()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions