-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent.java
80 lines (69 loc) · 1.91 KB
/
Student.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//@author Shreyan Wankavala
public class Student implements Cloneable{
private String name;
private double money;
/** Constructor method for the Student object
*
* @param name1 = name of the student
* @param money1 = the amount of money the student has
*/
public Student(String name1, double money1){
name = name1;
money = money1;
}
/** Method for changing the name of a student
*
* @param name1 = the name of the student
*/
public void setName(String name1){
name = name1;
}
/** Method for changing the amount of money a student has
*
* @param money1 = the amount of money a student has
*/
public void setMoney(double money1){
money = money1;
}
/** Method to return the name of the student
*
* @return the student's name
*/
public String getName(){
return name;
}
/** Method to return the amount of money a student has
*
* @return the student's money
*/
public double getMoney(){
return money;
}
/** Method to convert the name and money of a student into a string
*
* @return the name and money of a student
*/
public String toString(){
return name + " " + "$" + money + "\n";
}
/** Method to clone a student
*
* @return
*/
public Student clone(){
Student copy = new Student(this.getName(), this.getMoney());
return copy;
}
/** Method to check if the lunch line in each reality is equal
*
* @param obj = object parameter casted to Student
* @return = boolean value for if the money is the same
*/
public boolean equals(Object obj){
Student checkStudent = (Student)obj;
if(!this.getName().equals(checkStudent.getName())){
return false;
}
return this.getMoney() == checkStudent.getMoney();
}
}