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 | |
| parent | 215afef835b4153d8a33abdc0bafac440dae9d83 (diff) | |
| download | unterricht-2c17f1dad1bd9d76605226c602dc53b2983bcab7.tar.gz unterricht-2c17f1dad1bd9d76605226c602dc53b2983bcab7.zip | |
add BlueJ Prison project
| -rw-r--r-- | Info/10/2/Prison/GEFAENGNIS.ctxt | 9 | ||||
| -rwxr-xr-x | Info/10/2/Prison/GEFAENGNIS.java | 40 | ||||
| -rw-r--r-- | Info/10/2/Prison/Makefile | 15 | ||||
| -rw-r--r-- | Info/10/2/Prison/WACHE.ctxt | 7 | ||||
| -rwxr-xr-x | Info/10/2/Prison/WACHE.java | 16 | ||||
| -rw-r--r-- | Info/10/2/Prison/ZELLE.ctxt | 9 | ||||
| -rwxr-xr-x | Info/10/2/Prison/ZELLE.java | 22 | ||||
| -rw-r--r-- | Info/10/2/Prison/package.bluej | 55 |
8 files changed, 173 insertions, 0 deletions
diff --git a/Info/10/2/Prison/GEFAENGNIS.ctxt b/Info/10/2/Prison/GEFAENGNIS.ctxt new file mode 100644 index 00000000..5cda69a9 --- /dev/null +++ b/Info/10/2/Prison/GEFAENGNIS.ctxt @@ -0,0 +1,9 @@ +#BlueJ class context +comment0.target=GEFAENGNIS +comment1.params=zellenAnzahl +comment1.target=GEFAENGNIS(int) +comment2.params= +comment2.target=void\ run() +comment3.params=args +comment3.target=void\ main(java.lang.String[]) +numComments=4 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(); + } +} diff --git a/Info/10/2/Prison/Makefile b/Info/10/2/Prison/Makefile new file mode 100644 index 00000000..2f9922dc --- /dev/null +++ b/Info/10/2/Prison/Makefile @@ -0,0 +1,15 @@ +.PHONY: run all clean + +SRC := $(wildcard *.java) +OBJ := $(foreach src, $(SRC), $(subst .java,.class,$(src))) + +all: $(OBJ) + +run: all + @java GEFAENGNIS + +clean: + rm -f *.class + +%.class: %.java + javac $< diff --git a/Info/10/2/Prison/WACHE.ctxt b/Info/10/2/Prison/WACHE.ctxt new file mode 100644 index 00000000..187b674b --- /dev/null +++ b/Info/10/2/Prison/WACHE.ctxt @@ -0,0 +1,7 @@ +#BlueJ class context +comment0.target=WACHE +comment1.params=nummer +comment1.target=WACHE(int) +comment2.params=zellenNummer\ zelle +comment2.target=void\ Besuche(int,\ ZELLE) +numComments=3 diff --git a/Info/10/2/Prison/WACHE.java b/Info/10/2/Prison/WACHE.java new file mode 100755 index 00000000..03d3b7f1 --- /dev/null +++ b/Info/10/2/Prison/WACHE.java @@ -0,0 +1,16 @@ +public class WACHE +{ + private int id; + + public WACHE(int nummer) + { + id = nummer; + } + + public void Besuche(int zellenNummer, ZELLE zelle) + { + if (zellenNummer % id == 0) { + zelle.Umschalten(); + } + } +} diff --git a/Info/10/2/Prison/ZELLE.ctxt b/Info/10/2/Prison/ZELLE.ctxt new file mode 100644 index 00000000..9a57e525 --- /dev/null +++ b/Info/10/2/Prison/ZELLE.ctxt @@ -0,0 +1,9 @@ +#BlueJ class context +comment0.target=ZELLE +comment1.params= +comment1.target=ZELLE() +comment2.params= +comment2.target=void\ Umschalten() +comment3.params= +comment3.target=boolean\ IstVersperrt() +numComments=4 diff --git a/Info/10/2/Prison/ZELLE.java b/Info/10/2/Prison/ZELLE.java new file mode 100755 index 00000000..f698c73c --- /dev/null +++ b/Info/10/2/Prison/ZELLE.java @@ -0,0 +1,22 @@ +public class ZELLE +{ + private boolean versperrt; + + public ZELLE() + { + versperrt = true; + } + + public void Umschalten() + { + if (versperrt) { + versperrt = false; + } else { + versperrt = true; + } + } + + public boolean IstVersperrt() { + return versperrt; + } +} diff --git a/Info/10/2/Prison/package.bluej b/Info/10/2/Prison/package.bluej new file mode 100644 index 00000000..44840d5f --- /dev/null +++ b/Info/10/2/Prison/package.bluej @@ -0,0 +1,55 @@ +#BlueJ package file +dependency1.from=GEFAENGNIS +dependency1.to=ZELLE +dependency1.type=UsesDependency +dependency2.from=GEFAENGNIS +dependency2.to=WACHE +dependency2.type=UsesDependency +dependency3.from=WACHE +dependency3.to=ZELLE +dependency3.type=UsesDependency +editor.fx.0.height=0 +editor.fx.0.width=0 +editor.fx.0.x=0 +editor.fx.0.y=0 +objectbench.height=93 +objectbench.width=776 +package.divider.horizontal=0.6 +package.divider.vertical=0.8 +package.editor.height=393 +package.editor.width=672 +package.editor.x=2073 +package.editor.y=190 +package.frame.height=600 +package.frame.width=800 +package.numDependencies=3 +package.numTargets=3 +package.showExtends=true +package.showUses=true +project.charset=UTF-8 +readme.height=60 +readme.name=@README +readme.width=49 +readme.x=10 +readme.y=10 +target1.height=70 +target1.name=GEFAENGNIS +target1.showInterface=false +target1.type=ClassTarget +target1.width=120 +target1.x=210 +target1.y=40 +target2.height=70 +target2.name=ZELLE +target2.showInterface=false +target2.type=ClassTarget +target2.width=120 +target2.x=360 +target2.y=230 +target3.height=70 +target3.name=WACHE +target3.showInterface=false +target3.type=ClassTarget +target3.width=120 +target3.x=100 +target3.y=160 |
