diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-04-12 12:09:27 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-04-12 12:09:27 +0200 |
| commit | 2c17f1dad1bd9d76605226c602dc53b2983bcab7 (patch) | |
| tree | 0a4f76fb51032f716f8094069e83694ea2816755 /Info/10/2/Prison/GEFAENGNIS.java | |
| parent | 215afef835b4153d8a33abdc0bafac440dae9d83 (diff) | |
| download | unterricht-2c17f1dad1bd9d76605226c602dc53b2983bcab7.tar.gz unterricht-2c17f1dad1bd9d76605226c602dc53b2983bcab7.zip | |
add BlueJ Prison project
Diffstat (limited to 'Info/10/2/Prison/GEFAENGNIS.java')
| -rwxr-xr-x | Info/10/2/Prison/GEFAENGNIS.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Info/10/2/Prison/GEFAENGNIS.java b/Info/10/2/Prison/GEFAENGNIS.java new file mode 100755 index 00000000..86c1f272 --- /dev/null +++ b/Info/10/2/Prison/GEFAENGNIS.java @@ -0,0 +1,40 @@ +public class GEFAENGNIS +{ + private ZELLE zellen[]; + private WACHE wachen[]; + + public GEFAENGNIS(int zellenAnzahl) + { + zellen = new ZELLE[zellenAnzahl]; + wachen = new WACHE[zellenAnzahl]; + + for(int i = 0; i < zellenAnzahl; i++) { + zellen[i] = new ZELLE(); + wachen[i] = new WACHE(i + 1); + } + } + + public void run() + { + for (int i = 0; i < wachen.length; i++) { + for (int j = 0; j < zellen.length; j++) { + wachen[i].Besuche(j + 1, zellen[j]); + } + } + + String ausgabe = ""; + + for (int i = 0; i < zellen.length; i++) { + if (!zellen[i].IstVersperrt()) { + ausgabe += i + 1 + ", "; + } + } + + System.out.println(ausgabe); + } + + public static void main(String args[]) { + GEFAENGNIS gefaengnis = new GEFAENGNIS(100); + gefaengnis.run(); + } +} |
