Student - } public String getName() { return name; } public...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/*The student database contains each students' name, student ID, and year. */ public class Student implements Comparable<Student> { protected String name; protected int id; protected int year; p public Student() { name = "unknown"; id = 0; year = 1900; } public Student(String name, int id, int year) { setName(name); setId(id); setYear(year); } public void setName(String n) { this.name = n; } public void setId(int i) { this.id = i; } public void setYear(int y) { this.year = y;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public String getName() { return name; } public int getId() { return id; } public int getYear() { return year; } public String toString() { return(&quot;Student Name: &quot; + name + &quot; Id #: &quot; + id + &quot; Year: &quot; + year); } public int compareTo(Student another) { int result = 0; i if (this.id &lt; another.id) result = -1; else if (this.id == another.id) result = 0; else if (this.id &gt; another.id) result = 1; r return result; } }...
View Full Document

Page1 / 2

Student - } public String getName() { return name; } public...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online