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
2264d271
Commit
2264d271
authored
May 15, 2022
by
a-j.towse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP displayAnimalType
parent
292c1928
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
33 deletions
+40
-33
Animal.class
ZooProgram/bin/Animal.class
+0
-0
App.class
ZooProgram/bin/App.class
+0
-0
Zoo.class
ZooProgram/bin/Zoo.class
+0
-0
unitTest.class
ZooProgram/bin/unitTest.class
+0
-0
Animal.java
ZooProgram/src/Animal.java
+0
-1
App.java
ZooProgram/src/App.java
+1
-31
Zoo.java
ZooProgram/src/Zoo.java
+8
-0
unitTest.java
ZooProgram/src/unitTest.java
+31
-1
No files found.
ZooProgram/bin/Animal.class
View file @
2264d271
No preview for this file type
ZooProgram/bin/App.class
View file @
2264d271
No preview for this file type
ZooProgram/bin/Zoo.class
View file @
2264d271
No preview for this file type
ZooProgram/bin/unitTest.class
View file @
2264d271
No preview for this file type
ZooProgram/src/Animal.java
View file @
2264d271
...
...
@@ -35,7 +35,6 @@ public abstract class Animal {
detailList
.
add
(
detail1
);
}
public
String
getFoodType
(){
return
this
.
foodType
;
}
...
...
ZooProgram/src/App.java
View file @
2264d271
import
java.util.ArrayList
;
public
class
App
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
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
Fred
=
new
Bird
(
"Fred"
,
"pink feathers"
,
"savannah"
,
"shrimp"
,
false
,
true
);
myZoo
.
addanimal
(
Rex
);
myZoo
.
addanimal
(
Pix
);
myZoo
.
addanimal
(
Fred
);
myZoo
.
displayAnimalArrayList
();
myZoo
.
displayDetails
(
Rex
);
myZoo
.
displayfoodRequirements
(
Rex
);
myZoo
.
displayfoodRequirements
(
Fred
);
ArrayList
<
Animal
>
animalList
=
new
ArrayList
<>();
animalList
.
add
(
Rex
);
animalList
.
add
(
Pix
);
myZoo
.
displayfoodListRequirements
(
animalList
);
myZoo
.
displayListDetials
(
animalList
);
myZoo
.
displayEnvironmentList
(
"savannah"
);
}
}
}
ZooProgram/src/Zoo.java
View file @
2264d271
...
...
@@ -48,4 +48,12 @@ public class Zoo {
}
}
//WIP animal type, get class
public
void
displayAnimalType
(
String
animalType
){
for
(
int
i
=
0
;
i
<
animalArrayList
.
size
();
i
++){
if
(
animalArrayList
.
get
(
i
).
toString
()
==
animalType
){
}
}
}
}
\ No newline at end of file
ZooProgram/src/unitTest.java
View file @
2264d271
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
java.util.ArrayList
;
public
class
unitTest
{
@Test
public
void
testConstructors
(){
//Fish Constructor
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
);
...
...
@@ -19,4 +19,34 @@ public class unitTest {
assertEquals
(
"Tom"
,
Tom
.
getName
());
assertEquals
(
"green eyed crocodile"
,
Cameron
.
getDescription
());
}
@Test
public
void
testArrayList
(){
Zoo
myZoo
=
new
Zoo
();
Mammal
Tom
=
new
Mammal
(
"Tom"
,
"striped tiger"
,
"jungle"
,
"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
.
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"
);
}
}
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