-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment.java
193 lines (172 loc) · 3.87 KB
/
Assignment.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package ws.thurn.dossier;
/**
* The Assignment class stores information on Assignments, including the
* assignment name, the assignment weight, the number of marks the assignment is
* out of, and the category of the assignment.
*
* @author Derek Thurn
*/
public class Assignment
{
private String name;
// The name of the assignment
private int weight = 1;
// The weight of the assignment
private int totalMarks;
// The total marks that the assignment is out of
private Category category;
// The category of the assignment.
/**
* Specifies a blank assignment.
*/
public Assignment()
{
name = "";
totalMarks = 0;
}
/**
* Specifies an assignment with just a name.
*
* @param n
*/
public Assignment( String n )
{
name = n;
}
/**
* @param n
* @param tm Specifies an assignment with a name and total marks.
*/
public Assignment( String n, int tm )
{
name = n;
totalMarks = tm;
}
/**
* @param n
* @param tm
* @param w Specifies an assignment with a name, total marks, and a weight.
*/
public Assignment( String n, int tm, int w )
{
name = n;
totalMarks = tm;
weight = w;
}
/**
* @param n
* @param tm
* @param w
* @param c Specifies a full assignment with a name, total marks, weight,
* and category.
*/
public Assignment( String n, int tm, int w, Category c )
{
name = n;
totalMarks = tm;
weight = w;
category = c;
c.addAssignment( this );
}
/**
* Returns the Total Marks the assignment is out of.
*
* @return Returns the totalMarks.
* @pre totalMarks has a value
* @post none
*/
public int getTotalMarks()
{
return totalMarks;
}
/**
* Returns the assignment's name
*
* @return Returns the name.
* @pre none
* @post none
*/
public String getName()
{
return name;
}
/**
* Returns the assignment's weight.
*
* @return Returns the weight.
* @pre none
* @post none
*/
public int getWeight()
{
return weight;
}
/**
* Returns the assignment's category.
*
* @return Returns the category.
* @pre none
* @post none
*/
public Category getCategory()
{
if( category == null )
return new Category( "Assignment Has No Category X" );
else
return category;
}
/**
* Sets the assignment's category.
*
* @param category The category to set.
* @pre none
* @post the category has been set.
*/
public void setCategory( Category c )
{
category = c;
c.addAssignment( this );
}
/**
* Sets the assignment's total marks.
*
* @param totalMarks The totalMarks to set.
* @pre none
* @post the totalMarks have been set
*/
public void setTotalMarks( int tm )
{
totalMarks = tm;
}
/**
* Sets the assignment's name.
*
* @param name The name to set.
* @pre none
* @post the name has been set
*/
public void setName( String n )
{
name = n;
}
/**
* Sets the weight of the assignment.
*
* @param weight The weight to set.
* @pre none
* @post the weight has been set.
*/
public void setWeight( int w )
{
weight = w;
}
/**
* Returns the name of the assignment.
*
* @pre the assignment has a name.
*/
public String toString()
{
return name;
}
}