-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDepartment.java
executable file
·76 lines (65 loc) · 2.2 KB
/
Department.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
/**
* Write a description of class Department here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Department
{
// instance variables - replace the example below with your own
private String dep_name;
private Lecturer [] dep_lects = new Lecturer[0];
private Student [] dep_stns = new Student[0];
int lectsAmount = 0, stnAmount = 0, i;
/**
* Constructor for objects of class Department
*/
protected Department() {};
protected Department(String name)
{
// initialise instance variables
dep_name = name;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
protected void add_lec(Lecturer lec) {
if (lectsAmount >= dep_lects.length) {
Lecturer [] temp = new Lecturer[lectsAmount + 1];
for (i = 0; i < lectsAmount; i++)
temp[i] = dep_lects[i];
dep_lects = temp;
}
dep_lects[lectsAmount++] = lec;
}
protected void add_stn(Student stn) {
if (stnAmount >= dep_stns.length) {
Student [] temp = new Student[stnAmount + 1];
System.arraycopy(dep_stns, 0, temp, 0, stnAmount);
dep_stns = temp;
}
dep_stns[stnAmount++] = stn;
}
protected String getDepName() {
return dep_name;
}
public String toString() {
return "Department name: " + dep_name + ", Lecturers: " + lectsAmount + ", Students: " + stnAmount;
}
protected void get_dep_lects() {
if (lectsAmount == 0) System.out.println("No lecturers");
for (i = 0; i < lectsAmount; i++)
System.out.println("name: " + dep_lects[i].getName() + ", hourly: " + dep_lects[i].getHourly() + ", hash: " + dep_lects[i]);
}
protected void get_dep_stns() {
if (stnAmount == 0) System.out.println("No students");
for (i = 0; i < stnAmount; i++)
System.out.println("name: " + dep_stns[i].getName() + ", id: " + dep_stns[i].getId() + ", hash: " + dep_stns[i]);
}
protected int getAmountOfStns() {
return stnAmount;
}
}