Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AssessmentZooProgram
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
a-j.towse
AssessmentZooProgram
Commits
eaa41559
Commit
eaa41559
authored
May 16, 2022
by
a-j.towse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final commit with all working methods and comments to show
parent
e893fdc4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
Zoo.class
ZooProgram/bin/Zoo.class
+0
-0
Zoo.java
ZooProgram/src/Zoo.java
+11
-1
No files found.
ZooProgram/bin/Zoo.class
View file @
eaa41559
No preview for this file type
ZooProgram/src/Zoo.java
View file @
eaa41559
import
java.util.ArrayList
;
public
class
Zoo
{
//Stores a list of animals within the zoo
private
ArrayList
<
Animal
>
animalArrayList
=
new
ArrayList
<>();
public
ArrayList
<
Animal
>
getanimalArrayList
(){
...
...
@@ -21,12 +22,14 @@ public class Zoo {
System
.
out
.
println
(
animal
.
getFoodType
());
}
//displays the food required for all animals in an ArrayList
public
void
displayfoodListRequirements
(
ArrayList
<
Animal
>
animalList
){
for
(
int
i
=
0
;
i
<
animalList
.
size
();
i
++){
System
.
out
.
println
(
animalList
.
get
(
i
).
getFoodType
());
}
}
//displays the details of a single animal
public
void
displayDetails
(
Animal
animal
){
ArrayList
<
String
>
detailList
=
animal
.
getDetails
();
for
(
int
i
=
0
;
i
<
detailList
.
size
();
i
++){
...
...
@@ -34,12 +37,14 @@ public class Zoo {
}
}
//displays the details of each animal in an arrayList
public
void
displayListDetials
(
ArrayList
<
Animal
>
animalList
){
for
(
int
i
=
0
;
i
<
animalList
.
size
();
i
++){
displayDetails
(
animalList
.
get
(
i
));
}
}
//displays all animals from a specific environment
public
void
displayEnvironmentList
(
String
environment
){
for
(
int
i
=
0
;
i
<
animalArrayList
.
size
();
i
++){
if
(
animalArrayList
.
get
(
i
).
getEnvironment
()
==
environment
){
...
...
@@ -48,20 +53,25 @@ public class Zoo {
}
}
//
WIP animal type, get class
//
creates and displays an arrayList of animals of a particular type
public
void
displayAnimalType
(
String
animalType
){
ArrayList
<
Animal
>
typeArrayList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
animalArrayList
.
size
();
i
++){
if
(
animalArrayList
.
get
(
i
)
instanceof
Mammal
&&
animalType
==
"Mammal"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
typeArrayList
.
add
(
animalArrayList
.
get
(
i
));
}
if
(
animalArrayList
.
get
(
i
)
instanceof
Bird
&&
animalType
==
"Bird"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
typeArrayList
.
add
(
animalArrayList
.
get
(
i
));
}
if
(
animalArrayList
.
get
(
i
)
instanceof
Reptile
&&
animalType
==
"Reptile"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
typeArrayList
.
add
(
animalArrayList
.
get
(
i
));
}
if
(
animalArrayList
.
get
(
i
)
instanceof
Fish
&&
animalType
==
"Fish"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
typeArrayList
.
add
(
animalArrayList
.
get
(
i
));
}
}
}
...
...
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