-
Notifications
You must be signed in to change notification settings - Fork 0
/
TutorialSpace.java
64 lines (50 loc) · 1.66 KB
/
TutorialSpace.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
//import java.util.logging.Level;
//import java.util.logging.Logger;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author smoo
*/
public class TutorialSpace {
private int slots;
private String code;
private boolean activated;
public TutorialSpace(String classCode, int classSize) {
code = classCode;
slots = classSize;
}
public int slotsRemaining() {
return slots;
}
public void activate() {
if (activated) {
throw new RuntimeException(code + " is already activated"); //JVM throwing exception unless if it is not activated
}
activated = true; //activated(true);
}
public void reserveSlot() throws EmptyException, NotActivatedException {
if (activated == false)
throw new NotActivatedException(code + " is not activated");
if (slots == 0)
throw new EmptyException(code + " is full");
slots--;
}
}
//there is an error as it is not declared and does not have a throw clause
// public void reserveSlot() {
// if (activated == false)
// throw new NotActivatedException(code + " is not activated");
// }
//}
// public void reserveSlot() {
// if (activated == false)
// try {
// throw new NotActivatedException(code + " is not activated");
// } catch (NotActivatedException ex) {
// Logger.getLogger(TutorialSpace.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
//}