[Added] initial project
This commit is contained in:
commit
d52f770cf1
12 changed files with 332 additions and 0 deletions
66
.gitignore
vendored
Normal file
66
.gitignore
vendored
Normal file
|
|
@ -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
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Zoo.iml" filepath="$PROJECT_DIR$/Zoo.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
37
README.md
Normal file
37
README.md
Normal file
|
|
@ -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.
|
||||||
11
Zoo.iml
Normal file
11
Zoo.iml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
23
src/com/ing/zoo/Hippo.java
Normal file
23
src/com/ing/zoo/Hippo.java
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/com/ing/zoo/Lion.java
Normal file
23
src/com/ing/zoo/Lion.java
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/com/ing/zoo/Pig.java
Normal file
47
src/com/ing/zoo/Pig.java
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/com/ing/zoo/Tiger.java
Normal file
41
src/com/ing/zoo/Tiger.java
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/com/ing/zoo/Zebra.java
Normal file
26
src/com/ing/zoo/Zebra.java
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/com/ing/zoo/Zoo.java
Normal file
38
src/com/ing/zoo/Zoo.java
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in a new issue