Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
YSJ Zoo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harvey.young
YSJ Zoo
Commits
c45990dc
Commit
c45990dc
authored
May 10, 2020
by
harve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final
parents
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
256 additions
and
0 deletions
+256
-0
.classpath
.classpath
+10
-0
.project
.project
+17
-0
org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.core.prefs
+14
-0
.gitignore
bin/.gitignore
+2
-0
zooMain.java
src/zooMain.java
+213
-0
No files found.
.classpath
0 → 100644
View file @
c45990dc
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-12"
>
<attributes>
<attribute
name=
"module"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
.project
0 → 100644
View file @
c45990dc
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
ZooProject
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
c45990dc
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=12
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=12
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=12
bin/.gitignore
0 → 100644
View file @
c45990dc
/animal.class
/zooMain.class
src/zooMain.java
0 → 100644
View file @
c45990dc
import
java.util.ArrayList
;
import
java.util.Scanner
;
class
animal
{
public
String
animalName
;
public
String
animalType
;
public
String
animalFood
;
public
String
animalEnviroment
;
public
void
food
()
{
System
.
out
.
print
(
this
.
animalFood
);
}
public
void
type
()
{
System
.
out
.
print
(
this
.
animalType
);
}
public
void
enviroment
()
{
System
.
out
.
print
(
this
.
animalEnviroment
);
}
public
String
getFood
()
{
return
this
.
animalFood
;
}
public
String
getType
()
{
return
this
.
animalType
;
}
public
String
getEnviroment
()
{
return
this
.
animalEnviroment
;
}
public
String
getName
()
{
return
this
.
animalName
;
}
public
animal
(
String
animalNameInput
,
String
animalTypeInput
,
String
animalEnviromentInput
,
String
animalFoodInput
)
{
this
.
animalName
=
animalNameInput
;
this
.
animalEnviroment
=
animalEnviromentInput
;
this
.
animalFood
=
animalFoodInput
;
this
.
animalType
=
animalTypeInput
;
}
}
public
class
zooMain
{
static
ArrayList
<
String
>
animalList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
foodList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
catsList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
xList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
fishList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
birdList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
animalFood
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
forestList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
waterList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
arcticList
=
new
ArrayList
<
String
>();
static
ArrayList
<
String
>
heatList
=
new
ArrayList
<
String
>();
static
Scanner
input
=
new
Scanner
(
System
.
in
);
public
static
void
main
(
String
[]
args
)
{
animal
Tiger
=
new
animal
(
"Tiger"
,
"Cats"
,
"Heat"
,
"Meat"
);
animalList
.
add
(
"Tiger"
);
animal
Lion
=
new
animal
(
"Lion"
,
"Cats"
,
"Heat"
,
"Meat"
);
animalList
.
add
(
"Lion"
);
animal
Giraffe
=
new
animal
(
"Giraffe"
,
"X"
,
"Heat"
,
"Veg"
);
animalList
.
add
(
"Giraffe"
);
animal
Penguin
=
new
animal
(
"Penguin"
,
"X"
,
"Arctic"
,
"Fish"
);
animalList
.
add
(
"Penguin"
);
animal
Zebra
=
new
animal
(
"Zebra"
,
"X"
,
"Heat"
,
"Veg"
);
animalList
.
add
(
"Zebra"
);
animal
RainbowTrout
=
new
animal
(
"RainbowTrout"
,
"Fish"
,
"Water"
,
"Fish"
);
animal
Salmon
=
new
animal
(
"Salmon"
,
"Fish"
,
"Water"
,
"Fish"
);
animal
Pheasant
=
new
animal
(
"Pheasant"
,
"Bird"
,
"Forest"
,
"Seed"
);
animal
Pigeon
=
new
animal
(
"Pigeon"
,
"Bird"
,
"Forest"
,
"Seed"
);
animalList
.
add
(
"Salmon"
);
animalList
.
add
(
"Pheasant"
);
animalList
.
add
(
"Pigeon"
);
animalList
.
add
(
"RainbowTrout"
);
catsList
.
add
(
Tiger
.
getName
());
catsList
.
add
(
Lion
.
getName
());
xList
.
add
(
Penguin
.
getName
());
xList
.
add
(
Giraffe
.
getName
());
xList
.
add
(
Zebra
.
getName
());
fishList
.
add
(
RainbowTrout
.
getName
());
fishList
.
add
(
Salmon
.
getName
());
birdList
.
add
(
Pigeon
.
getName
());
birdList
.
add
(
Pheasant
.
getName
());
animalFood
.
add
(
Tiger
.
getFood
());
animalFood
.
add
(
Lion
.
getFood
());
animalFood
.
add
(
Giraffe
.
getFood
());
animalFood
.
add
(
Penguin
.
getFood
());
animalFood
.
add
(
Zebra
.
getFood
());
animalFood
.
add
(
Salmon
.
getFood
());
animalFood
.
add
(
RainbowTrout
.
getFood
());
animalFood
.
add
(
Pheasant
.
getFood
());
animalFood
.
add
(
Pigeon
.
getFood
());
forestList
.
add
(
Pigeon
.
getName
());
forestList
.
add
(
Pheasant
.
getName
());
heatList
.
add
(
Zebra
.
getName
());
heatList
.
add
(
Lion
.
getName
());
heatList
.
add
(
Tiger
.
getName
());
heatList
.
add
(
Giraffe
.
getName
());
waterList
.
add
(
Salmon
.
getName
());
waterList
.
add
(
RainbowTrout
.
getName
());
arcticList
.
add
(
Penguin
.
getName
());
while
(
true
)
{
System
.
out
.
println
(
"Welcome to YSJ Zoo"
+
"\n"
+
"Please select an option: "
+
"\n"
+
"1 - Display all animals in zoo."
+
"\n"
+
"2 - Filter animals to type. "
+
"\n"
+
"3 - Display info on an animal. "
+
"\n"
+
"4 - Food required from all animals. "
+
"\n"
+
"5 - Display animals from a specific enviroment."
);
int
userInput
=
input
.
nextInt
();
if
(
userInput
==
1
)
{
System
.
out
.
println
(
"These are all the animals in my zoo: "
+
animalList
);
}
else
if
(
userInput
==
2
)
{
System
.
out
.
println
(
"These are our animal types: (Cats/No Group(X)/Birds/Fish)"
);
System
.
out
.
println
(
"Which type do you want to see? "
);
String
filterType
=
input
.
next
();
switch
(
filterType
)
{
case
"Cats"
:
System
.
out
.
println
(
"These animals are members of the cats type: "
+
catsList
);
return
;
case
"X"
:
System
.
out
.
println
(
"These animals are members of the no group type: "
+
xList
);
return
;
case
"Fish"
:
System
.
out
.
println
(
"These animals are members of the fish type: "
+
fishList
);
return
;
case
"Birds"
:
System
.
out
.
println
(
"These animals are members of the bird type: "
+
birdList
);
return
;
}
}
else
if
(
userInput
==
3
)
{
System
.
out
.
println
(
"Which animal would you like more info on: "
+
animalList
);
String
animalChoice
=
input
.
next
();
switch
(
animalChoice
)
{
case
"Tiger"
:
System
.
out
.
println
(
"Name: Tiger"
);
System
.
out
.
print
(
"The food they eat: "
);
Tiger
.
food
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"Type of animal group: "
);
Tiger
.
type
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"They enviroment they live in: "
);
Tiger
.
enviroment
();
System
.
out
.
print
(
"\n"
);
return
;
case
"Lion"
:
System
.
out
.
println
(
"Name: Lion"
);
System
.
out
.
print
(
"The food they eat: "
);
Lion
.
food
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"Type of animal group: "
);
Lion
.
type
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"They enviroment they live in: "
);
Lion
.
enviroment
();
System
.
out
.
print
(
"\n"
);
return
;
case
"Giraffe"
:
System
.
out
.
println
(
"Name: Giraffe"
);
System
.
out
.
print
(
"The food they eat: "
);
Giraffe
.
food
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"Type of animal group: "
);
Giraffe
.
type
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"They enviroment they live in: "
);
Giraffe
.
enviroment
();
System
.
out
.
print
(
"\n"
);
return
;
case
"Penguin"
:
System
.
out
.
println
(
"Name: Penguin"
);
System
.
out
.
print
(
"The food they eat: "
);
Penguin
.
food
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"Type of animal group: "
);
Penguin
.
type
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"They enviroment they live in: "
);
Penguin
.
enviroment
();
System
.
out
.
print
(
"\n"
);
return
;
case
"Zebra"
:
System
.
out
.
println
(
"Name: Zebra"
);
System
.
out
.
print
(
"The food they eat: "
);
Zebra
.
food
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"Type of animal group: "
);
Zebra
.
type
();
System
.
out
.
print
(
"\n"
);
System
.
out
.
print
(
"They enviroment they live in: "
);
Zebra
.
enviroment
();
System
.
out
.
print
(
"\n"
);
return
;
}
}
else
if
(
userInput
==
4
)
{
System
.
out
.
println
(
"The food the aimals eat are as followed: "
+
animalFood
);
}
else
if
(
userInput
==
5
)
{
System
.
out
.
println
(
"Which enviroment do you want to see the animals from?"
);
System
.
out
.
println
(
"Heat/Water/Arctic/Forest"
);
String
enviroChoice
=
input
.
next
();
switch
(
enviroChoice
)
{
case
"Heat"
:
System
.
out
.
println
(
"The animals that live in a heated enviroment are: "
+
heatList
);
return
;
case
"Water"
:
System
.
out
.
println
(
"The animals that live in the water are: "
+
waterList
);
return
;
case
"Arctic"
:
System
.
out
.
println
(
"The only animal to live in the arctic area is: "
+
arcticList
);
return
;
case
"Forest"
:
System
.
out
.
println
(
"The animals that live in the forest are: "
+
forestList
);
return
;
}
}
}
}}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment