Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question on the top is the one to do thank you! /* * Student.java * * A Student class * */ public class Student

The question on the top is the one to do thank you!image text in transcribedimage text in transcribed

/* * Student.java * * A Student class * */ public class Student { private String sID; // unique student ID private int grade; // % grade (-1 if no initial 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)); } }

* /* * Purpose: creates a new array i longer than students and adds all students and s to the new array * Parameters: Student[] - students, Student s * Returns: Student[] - the new array * Preconditions: students is not null and contains no null elements Student s is not already contained within students */ // ToDo: implement registerStudent // public static void testRegisterStudent() { // TODO: write tests for Lab2.registerStudent // HINT: the Student class also has a equals method so you // can use Arrays.equals again to compare 2 Student arrays // } public static void displayResults (boolean passed, String testName) { /* There is some magic going on here getting the line number * Borrowed from: * http://blog.taragana.com/index.php/archive/core-java-how-to-get-java-source-code-line-number-file-name-in-code/ */ testCount++; if (passed) { System.out.println ("Passed test: " + testName); test PassCount++; } else { System.out.println ("Failed test: " + testName + " at line " + Thread.currentThread().getStackTrace() [2].getLineNumber()); } }

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

Step: 3

blur-text-image

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

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions

Question

2. How do they influence my actions?

Answered: 1 week ago