-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
47 lines (41 loc) · 1.43 KB
/
Copy pathStudent.java
File metadata and controls
47 lines (41 loc) · 1.43 KB
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
public class Student {
private String studentId;
private String name;
private String email;
private String password;
private int loyaltyPoints;
public Student(String studentId, String name, String email, String password) {
this.studentId = studentId;
this.name = name;
this.email = email;
this.password = password;
this.loyaltyPoints = 0;
}
public String getStudentId() { return studentId; }
public String getName() { return name; }
public String getEmail() { return email; }
public String getPassword() { return password; }
public int getLoyaltyPoints() { return loyaltyPoints; }
public void addLoyaltyPoints(int points) {
if (points > 0) loyaltyPoints += points;
}
public boolean redeemPoints(int points) {
if (points > 0 && loyaltyPoints >= points) {
loyaltyPoints -= points;
return true;
}
return false;
}
public void setName(String name) { this.name = name; }
public void setEmail(String email) { this.email = email; }
public void setPassword(String password) { this.password = password; }
@Override
public String toString() {
return "Student{" +
"studentId='" + studentId + '\'' +
", name='" + name + '\'' +
", email='" + email + '\'' +
", loyaltyPoints=" + loyaltyPoints +
'}';
}
}