forked from AUT-AP-2020/workshop-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniversity.java
49 lines (41 loc) · 1.17 KB
/
University.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
package ir.ac.aut;
import java.util.ArrayList;
public class University {
private ArrayList<Lab> labs;
//since the number of labs could change -> dynamic memory -> ArrayList
public University()
{
labs= new ArrayList<>();
}
public void addLab(Lab newLab){
labs.add(newLab);
return;
}
public boolean removeLab(Lab beRemoved){
for(int i=0; i<getNumLabs(); i++){
if(labs.get(i).equals(beRemoved)){
labs.remove(i);
return true;
}
}
return false;
}
public Lab getLab(int index){
return labs.get(index);
}
public int getNumLabs(){
return labs.size();
}
public void printInfoLabs(){
if(getNumLabs()!=0) {
System.out.println("this Faculty has " + getNumLabs() + " labs");
for (int i = 0; i < getNumLabs(); i++) {
System.out.println((i + 1) + ") ");
labs.get(i).print();
System.out.println();
}
return;
}
System.out.println("no Labs in this Faculty");
}
}