commit d52f770cf1add707e03c04cd7e58b7c3d5337514 Author: Kwok Yee Chu Date: Sun May 12 19:41:40 2019 +0200 [Added] initial project diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b010a96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..29bc11f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6db4216 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Zoo Java Console Application +--- +## Git + +Voor het maken van deze opdracht wordt er gebruik gemaakt van het versiebeheersysteem Git. + +Gebruikte **IDE**: [IntelliJ IDEA](https://www.jetbrains.com/idea/). (**Niet verplicht**) + +Gebruikte **SDK**: [JDK 1.8](https://bitbucket.org/kychu/zoo/downloads/java-1.8.0-openjdk-1.8.0.212-3.b04.redhat.windows.x86_64.zip). + +Mocht er problemen zijn met het openen van dit project, creëer dan een nieuw project binnen jouw IDE en kopieer de Java bestanden uit `src/com/ing/zoo` + +Stappen: + +1. Clone deze repository. +2. Maak een nieuwe repository aan, bijvoorbeeld op [Github](https://www.github.com). +3. Push jouw veranderingen naar jouw repository. +4. Maak jouw repository openbaar (public). +4. Als de applicatie af is, push dan de laatste versie naar jouw `master` branch. + +--- +## Opdracht +- Maak de applicatie af. +- Reorganiseer eventueel de folder structuur. +- Refactor eventueel de code (denk goed na over de class structure). + - Probeer er voor de zorgen dat je bijvoorbeeld geen EatMeat methode kan aanroepen op een Zebra object. +- Voeg 2 nieuwe dieren toe. +--- +## Eisen + +Bij elke command laat je het resultaat in de console zien. + +- Als je de [hello] command uitvoert zonder dat er een naam is ingevuld zeggen alle dieren hallo. + - Als er wel een naam is ingevuld [hello henk] zegt alleen dat dier hallo +- Als je de [give leaves] command uitvoert krijgen alle herbivores leaves. +- Als je de [give meat] command uitvoert krijgen alle carnivores meat. +- Als je de [perform trick] command uitvoert doen alle dieren die dat kunnen hun trucje. diff --git a/Zoo.iml b/Zoo.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Zoo.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/com/ing/zoo/Hippo.java b/src/com/ing/zoo/Hippo.java new file mode 100644 index 0000000..908dfb4 --- /dev/null +++ b/src/com/ing/zoo/Hippo.java @@ -0,0 +1,23 @@ +package com.ing.zoo; + +public class Hippo { + public String name; + public String helloText; + public String eatText; + + public Hippo() + { + } + + public void sayHello() + { + helloText = "splash"; + System.out.println(helloText); + } + + public void eatLeaves() + { + eatText = "munch munch lovely"; + System.out.println(eatText); + } +} diff --git a/src/com/ing/zoo/Lion.java b/src/com/ing/zoo/Lion.java new file mode 100644 index 0000000..b31a046 --- /dev/null +++ b/src/com/ing/zoo/Lion.java @@ -0,0 +1,23 @@ +package com.ing.zoo; + +public class Lion { + public String name; + public String helloText; + public String eatText; + + public Lion() + { + } + + public void sayHello() + { + helloText = "roooaoaaaaar"; + System.out.println(helloText); + } + + public void eatMeat() + { + eatText = "nomnomnom thx mate"; + System.out.println(eatText); + } +} diff --git a/src/com/ing/zoo/Pig.java b/src/com/ing/zoo/Pig.java new file mode 100644 index 0000000..5db60e1 --- /dev/null +++ b/src/com/ing/zoo/Pig.java @@ -0,0 +1,47 @@ +package com.ing.zoo; + +import java.util.Random; + +public class Pig { + public String name; + public String helloText; + public String eatText; + public String trick; + + public Pig() + { + } + + public void sayHello() + { + helloText = "splash"; + System.out.println(helloText); + } + + public void eatLeaves() + { + eatText = "munch munch oink"; + System.out.println(eatText); + } + + public void eatMeat() + { + eatText = "nomnomnom oink thx"; + System.out.println(eatText); + } + + public void performTrick() + { + Random random = new Random(); + int rnd = random.nextInt(2); + if(rnd == 0) + { + trick = "rolls in the mud"; + } + else + { + trick = "runs in circles"; + } + System.out.println(trick); + } +} diff --git a/src/com/ing/zoo/Tiger.java b/src/com/ing/zoo/Tiger.java new file mode 100644 index 0000000..0467189 --- /dev/null +++ b/src/com/ing/zoo/Tiger.java @@ -0,0 +1,41 @@ +package com.ing.zoo; + +import java.util.Random; + +public class Tiger { + public String name; + public String helloText; + public String eatText; + public String trick; + + public Tiger() + { + } + + public void sayHello() + { + helloText = "rraaarww"; + System.out.println(helloText); + } + + public void eatMeat() + { + eatText = "nomnomnom oink wubalubadubdub"; + System.out.println(eatText); + } + + public void performTrick() + { + Random random = new Random(); + int rnd = random.nextInt(2); + if(rnd == 0) + { + trick = "jumps in tree"; + } + else + { + trick = "scratches ears"; + } + System.out.println(trick); + } +} diff --git a/src/com/ing/zoo/Zebra.java b/src/com/ing/zoo/Zebra.java new file mode 100644 index 0000000..2b8e97a --- /dev/null +++ b/src/com/ing/zoo/Zebra.java @@ -0,0 +1,26 @@ +package com.ing.zoo; + +import java.util.Random; + +public class Zebra { + public String name; + public String helloText; + public String eatText; + public String trick; + + public Zebra() + { + } + + public void sayHello() + { + helloText = "zebra zebra"; + System.out.println(helloText); + } + + public void eatLeaves() + { + eatText = "munch munch zank yee bra"; + System.out.println(eatText); + } +} diff --git a/src/com/ing/zoo/Zoo.java b/src/com/ing/zoo/Zoo.java new file mode 100644 index 0000000..8ebbc56 --- /dev/null +++ b/src/com/ing/zoo/Zoo.java @@ -0,0 +1,38 @@ +package com.ing.zoo; + +import java.util.Scanner; + +public class Zoo { + public static void main(String[] args) + { + String[] commands = new String[4]; + commands[0] = "hello"; + commands[1] = "give leaves"; + commands[2] = "give meat"; + commands[3] = "perform trick"; + + Lion henk = new Lion(); + henk.name = "henk"; + Hippo elsa = new Hippo(); + elsa.name = "elsa"; + Pig dora = new Pig(); + dora.name = "dora"; + Tiger wally = new Tiger(); + wally.name = "wally"; + Zebra marty = new Zebra(); + marty.name = "marty"; + + Scanner scanner = new Scanner(System.in); + System.out.print("Voer uw command in: "); + + String input = scanner.nextLine(); + if(input.equals(commands[0] + " henk")) + { + henk.sayHello(); + } + else + { + System.out.println("Unknown command: " + input); + } + } +}