-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurriculum.java
More file actions
69 lines (57 loc) · 2.04 KB
/
Copy pathCurriculum.java
File metadata and controls
69 lines (57 loc) · 2.04 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package TrainingProgram;
import java.util.Date;
enum STATUS { черновик, составлена, утверждена, архив }
class Curriculum {
protected int code;
protected Date creationDate, confirmationDate;
protected static final int COURSE_SIZE = 5;
protected static Course[] storage = new Course[COURSE_SIZE];
protected int status;
Curriculum() { }
Curriculum(Student student_, int code_, Date creationDate_, Date confirmationDate_) {
this.code = code_;
this.creationDate = creationDate_;
this.confirmationDate = confirmationDate_;
}
void print() {
System.out.println("code: " + code + " creationDate: " + creationDate + " confirmationDate: " + confirmationDate + "\nCourses:");
for (int i = 0; i < storage.length; i++)
System.out.println("Title: " + storage[i].title);
}
void add(Course course, int index) {
storage[index] = course;
System.out.println("Курс: " + storage[index].title + " успешно добавлен в Вашу учебную программу, кол-во кредитных единиц курса: "
+ (int)(storage[index].lectureHours + 1.25 * storage[index].practiceHours) / 18);
}
boolean contains(String str) {
for (int i = 0; i < storage.length; i++)
if (str.equals(storage[i].title)) return true;
return false;
}
boolean delete(int code, int ruleCode, Date date, Degree degree) {
try {
int cnt = 0;
for (int i = 0; i < storage.length; i++)
if (storage[i].code == code) cnt++;
int ecx = 0;
Course[] tmp = new Course[COURSE_SIZE - cnt];
for (int i = 0; i < storage.length; i++)
if (storage[i].code != code) {
tmp[ecx] = storage[i];
ecx++;
}
storage = tmp;
if (degree.setRule(ruleCode, date))
return true;
} catch(NullPointerException e) {
System.out.println("Error, NULLPTR exception!");
}
return false;
}
String getStatus() {
return STATUS.values()[status - 1].name();
}
void setStatus(int id) {
status = id;
}
}