-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreasure-2.txt
91 lines (69 loc) · 1.77 KB
/
Treasure-2.txt
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
class TreasureChest {
public static void main(String[] args) {
TreasureChest chest = new TreasureChest();
report(chest.getDescription());
scenarioHeader("Unlock then open:");
chest.unlock();
report(chest.getDescription());
chest.open();
report(chest.getDescription());
scenarioHeader("Lock from opened state:");
chest.lock();
report(chest.getDescription());
scenarioHeader("Lock from closed state:");
chest.unlock();
chest.open();
chest.close();
chest.lock();
report(chest.getDescription());
}
static void report(String message) {
System.out.println(message);
}
static void scenarioHeader(String message) {
report("\n"+message);
report("------------------------------".substring(1,message.length()));
}
String getDescription() {
return "The old treasure chest is " + chestStatus() + ".";
}
ChestLid {
Locked{
String chestStatus(){return "locked";}
[playerHasKey()] unlock -> Closed;
}
Unlocked{
Closed {
String chestStatus() {return "closed";}
[playerHasKey()] lock / {
report("You closed the lid of the chest.");
report("You lock the chest with your key.");
} -> Locked;
open / {report("You hear a creaking sound.");} -> Opened;
}
Opened {
String chestStatus() {return "open";}
[playerHasKey()] lock / {
report("Thud! The chest closes with a loud noise");
report("You lock the chest with your key.");
} -> Locked;
close / {
report("Thud! The chest closes with a loud noise.");
} -> Closed;
}
}
}
Boolean playerHasKey(){
return true;
}
}
//$?[End_of_model]$?
namespace -;
class TreasureChest
{
position 50 30 109 45;
}
class TreasureChest
{
position 50 30 109 45;
}