Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- private static int _COUNTER = 1500000;
- private final int id;
- private final String name;
- private int semester;
- public Student(String name, int semester){
- _COUNTER += (Math.random()*100)+100;
- id = _COUNTER;
- this.name = name;
- this.semester = semester;
- }
- public int getID(){
- return id;
- }
- public int getSemester(){
- return semester;
- }
- public String getNmae(){
- return name;
- }
- public void incSemester(){
- semester++;
- }
- @Override
- public String toString(){
- return String.format("%s; %d; %d", name, id, semester);
- }
- @Override
- public boolean equals(Object o){
- if (o == null) return false;
- if (this == o) return true;
- if(o instanceof Student){
- Student that = (Student) o;
- return this.id==that.id && this.semester == that.semester &&this.name.equals(that.name);
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement