Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
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
tahsif.ahmed
Zoo
Commits
3f0d8f21
Commit
3f0d8f21
authored
May 15, 2022
by
tahsif.ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
300579f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
main.java
main.java
+75
-0
No files found.
main.java
0 → 100644
View file @
3f0d8f21
import
java.util.Scanner
;
import
java.util.ArrayList
;
public
class
main
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
animal
animal1
=
new
animal
(
"Kong"
,
"Gorilla"
,
"Jungle"
,
120
,
200
,
"Omivore"
);
animal
animal3
=
new
animal
(
"George"
,
"Monkey"
,
"Jungle"
,
50
,
100
,
"Omivore"
);
animal
animal4
=
new
animal
(
"Leo"
,
"Lion"
,
"Savana"
,
200
,
200
,
"Carnivore"
);
animal
animal5
=
new
animal
(
"Zebby"
,
"Zebra"
,
"Savana"
,
90
,
140
,
"Herbivore"
);
reptile
animal6
=
new
reptile
(
"Liz"
,
"Lizard"
,
"Jungle"
,
1
,
20
,
"Carnivore"
);
aquatic
animal7
=
new
aquatic
(
"Bob"
,
"Dolphin"
,
"Ocean"
,
80
,
120
,
"Carnivore"
,
true
,
"Salt Water"
);
Scanner
scanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Enter name of animal"
);
String
userName
=
scanner
.
nextLine
();
System
.
out
.
println
(
"Enter species of animal"
);
String
userSpecies
=
scanner
.
nextLine
();
System
.
out
.
println
(
"Enter which biome the animal lives in"
);
String
userBiome
=
scanner
.
nextLine
();
System
.
out
.
println
(
"Enter weight of animal"
);
double
userWeight
=
scanner
.
nextDouble
();
System
.
out
.
println
(
"Enter height of animal"
);
double
userHeight
=
scanner
.
nextDouble
();
System
.
out
.
println
(
"What does the animal eat"
);
String
userFood
=
scanner
.
nextLine
();
animal
animal2
=
new
animal
(
userName
,
userSpecies
,
userBiome
,
userWeight
,
userHeight
,
userFood
);
ArrayList
<
animal
>
storeAnimal
=
new
ArrayList
<
animal
>();
storeAnimal
.
add
(
animal1
);
storeAnimal
.
add
(
animal2
);
storeAnimal
.
add
(
animal3
);
storeAnimal
.
add
(
animal4
);
storeAnimal
.
add
(
animal5
);
storeAnimal
.
add
(
animal6
);
storeAnimal
.
add
(
animal7
);
for
(
int
x
=
0
;
x
<
storeAnimal
.
size
();
x
++){
System
.
out
.
println
(
storeAnimal
.
get
(
x
).
name
+
" "
+
storeAnimal
.
get
(
x
).
species
+
" "
+
storeAnimal
.
get
(
x
).
biome
+
" "
+
storeAnimal
.
get
(
x
).
weight
+
"KG "
+
storeAnimal
.
get
(
x
).
height
+
"CM "
+
storeAnimal
.
get
(
x
).
foodType
+
" "
);
}
System
.
out
.
println
(
"Enter speicies name of the animal(s): "
);
String
searchSpecies
=
scanner
.
nextLine
();
for
(
int
x
=
0
;
x
<
storeAnimal
.
size
();
x
++){
if
(
storeAnimal
.
get
(
x
).
species
.
equals
(
searchSpecies
)){
System
.
out
.
println
(
storeAnimal
.
get
(
x
).
name
);
}
else
;
}
System
.
out
.
println
(
"Enter the food type: "
);
String
searchFood
=
scanner
.
nextLine
();
for
(
int
x
=
0
;
x
<
storeAnimal
.
size
();
x
++){
if
(
storeAnimal
.
get
(
x
).
foodType
.
equals
(
searchFood
)){
System
.
out
.
println
(
storeAnimal
.
get
(
x
).
name
);
}
else
;
}
}
}
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