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
e893fdc4
Commit
e893fdc4
authored
May 16, 2022
by
a-j.towse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final commit, all methods working correctly and in line with marking rubric
parent
2264d271
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
2 deletions
+53
-2
App.class
ZooProgram/bin/App.class
+0
-0
Zoo.class
ZooProgram/bin/Zoo.class
+0
-0
unitTest.class
ZooProgram/bin/unitTest.class
+0
-0
App.java
ZooProgram/src/App.java
+38
-1
Zoo.java
ZooProgram/src/Zoo.java
+12
-1
unitTest.java
ZooProgram/src/unitTest.java
+3
-0
No files found.
ZooProgram/bin/App.class
View file @
e893fdc4
No preview for this file type
ZooProgram/bin/Zoo.class
View file @
e893fdc4
No preview for this file type
ZooProgram/bin/unitTest.class
View file @
e893fdc4
No preview for this file type
ZooProgram/src/App.java
View file @
e893fdc4
import
java.util.ArrayList
;
public
class
App
{
public
class
App
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Zoo
myZoo
=
new
Zoo
();
Fish
Rex
=
new
Fish
(
"Rex"
,
"red stripes"
,
"sea"
,
"sea-weed"
,
12.5
,
"freshwater"
);
Fish
Pix
=
new
Fish
(
"Pix"
,
"gold"
,
"river"
,
"smaller fish"
,
5.0
,
"saltwater"
);
Bird
Rob
=
new
Bird
(
"Rob"
,
"red robin"
,
"large tree"
,
"seeds"
,
false
,
true
);
Mammal
Tom
=
new
Mammal
(
"Tom"
,
"striped tiger"
,
"savannah"
,
"meat"
,
90.0
,
120.0
);
Reptile
Cameron
=
new
Reptile
(
"Cam"
,
"green eyed crocodile"
,
"salt water"
,
"chicken"
,
182.5
,
230.0
);
myZoo
.
addanimal
(
Tom
);
myZoo
.
addanimal
(
Cameron
);
myZoo
.
addanimal
(
Rex
);
myZoo
.
addanimal
(
Pix
);
myZoo
.
addanimal
(
Rob
);
myZoo
.
displayAnimalArrayList
();
myZoo
.
displayDetails
(
Tom
);
myZoo
.
displayfoodRequirements
(
Tom
);
myZoo
.
displayfoodRequirements
(
Cameron
);
ArrayList
<
Animal
>
animalList
=
new
ArrayList
<>();
animalList
.
add
(
Tom
);
animalList
.
add
(
Cameron
);
myZoo
.
displayfoodListRequirements
(
animalList
);
myZoo
.
displayListDetials
(
animalList
);
myZoo
.
displayEnvironmentList
(
"savannah"
);
myZoo
.
displayAnimalType
(
"Reptile"
);
myZoo
.
displayAnimalType
(
"Fish"
);
}
}
}
}
ZooProgram/src/Zoo.java
View file @
e893fdc4
...
@@ -51,9 +51,20 @@ public class Zoo {
...
@@ -51,9 +51,20 @@ public class Zoo {
//WIP animal type, get class
//WIP animal type, get class
public
void
displayAnimalType
(
String
animalType
){
public
void
displayAnimalType
(
String
animalType
){
for
(
int
i
=
0
;
i
<
animalArrayList
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
animalArrayList
.
size
();
i
++){
if
(
animalArrayList
.
get
(
i
).
toString
()
==
animalType
){
if
(
animalArrayList
.
get
(
i
)
instanceof
Mammal
&&
animalType
==
"Mammal"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
}
if
(
animalArrayList
.
get
(
i
)
instanceof
Bird
&&
animalType
==
"Bird"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
}
if
(
animalArrayList
.
get
(
i
)
instanceof
Reptile
&&
animalType
==
"Reptile"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
}
if
(
animalArrayList
.
get
(
i
)
instanceof
Fish
&&
animalType
==
"Fish"
){
System
.
out
.
println
(
animalArrayList
.
get
(
i
).
getName
());
}
}
}
}
}
}
}
}
\ No newline at end of file
ZooProgram/src/unitTest.java
View file @
e893fdc4
...
@@ -2,6 +2,9 @@ import static org.junit.Assert.assertEquals;
...
@@ -2,6 +2,9 @@ import static org.junit.Assert.assertEquals;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
//Used to test in progress, currently not in use
public
class
unitTest
{
public
class
unitTest
{
@Test
@Test
...
...
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