-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrade.java
56 lines (51 loc) · 1.09 KB
/
Grade.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
/*
* Created by Noah Shaw
*/
public class Grade {
//Instance variables
private String name;
private int score;
//Constructors
public Grade()
{
this.name = "lab";
this.score = 100;
}
public Grade(String aName, int aScore)
{
this.setName(aName);
this.setScore(aScore);
}
//Accessors
public String getName()
{
return this.name;
}
public int getScore()
{
return this.score;
}
//Mutators
public void setName(String aName)
{
if(aName.equalsIgnoreCase("labs") || aName.equalsIgnoreCase("lab reports") || aName.equalsIgnoreCase("homework") || aName.equalsIgnoreCase("exam 1") || aName.equalsIgnoreCase("exam 2") || aName.equalsIgnoreCase("lab exam 1") || aName.equalsIgnoreCase("lab exam 2") || aName.equalsIgnoreCase("final") || aName.equalsIgnoreCase("extra credit"))
{
this.name = aName;
}
else
{
System.out.println("Invalid assignment");
}
}
public void setScore(int aScore)
{
if(aScore >= 0 && aScore <= 100)
{
this.score = aScore;
}
else
{
System.out.println("Invalid score");
}
}
}