Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
COM4005M - Zoo Simulator
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
harry.sawdon
COM4005M - Zoo Simulator
Commits
84365613
Commit
84365613
authored
Apr 28, 2021
by
harry.sawdon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
second commit
parent
8fec08e3
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
556 deletions
+43
-556
Animal.java
InheritanceTest/src/inheritanceTest/Animal.java
+4
-4
Bird.java
InheritanceTest/src/inheritanceTest/Bird.java
+3
-3
Fish.java
InheritanceTest/src/inheritanceTest/Fish.java
+3
-3
Mammal.java
InheritanceTest/src/inheritanceTest/Mammal.java
+3
-3
Reptile.java
InheritanceTest/src/inheritanceTest/Reptile.java
+3
-3
Test.java
InheritanceTest/src/inheritanceTest/Test.java
+27
-27
test1.java
InheritanceTest/src/inheritanceTest/test1.java
+0
-513
No files found.
InheritanceTest/src/inheritanceTest/Animal.java
View file @
84365613
package
inheritanceTest
;
public
class
Animal
{
public
class
Animal
{
// defines custom class animal to set up inheritance system.
// definition of argument names and data types
protected
String
name
;
protected
String
enviro
;
protected
String
eats
;
...
...
@@ -13,7 +13,7 @@ public class Animal {
public
Animal
(){}
public
Animal
(
String
Name
,
String
habitat
,
String
food
,
String
legs
,
String
wingspan
,
String
length
,
String
description
){
public
Animal
(
String
Name
,
String
habitat
,
String
food
,
String
legs
,
String
wingspan
,
String
length
,
String
description
){
//assigns arguments to animal class and all extensions
this
.
name
=
Name
;
this
.
enviro
=
habitat
;
this
.
eats
=
food
;
...
...
@@ -22,7 +22,7 @@ public class Animal {
this
.
Length
=
length
;
this
.
Description
=
description
;
}
// sets return parameters for each argument
public
String
getName
()
{
return
name
;
}
...
...
InheritanceTest/src/inheritanceTest/Bird.java
View file @
84365613
package
inheritanceTest
;
public
class
Bird
extends
Animal
{
public
class
Bird
extends
Animal
{
//defines bird class as extension of animal
public
Bird
(
String
Name
,
String
habitat
,
String
food
,
String
legs
,
String
wingspan
,
String
length
,
String
Description
)
{
super
(
Name
,
habitat
,
food
,
legs
,
wingspan
,
length
,
Description
);
super
(
Name
,
habitat
,
food
,
legs
,
wingspan
,
length
,
Description
);
// provides arguments for bird type animal
}
...
...
@@ -12,7 +12,7 @@ public class Bird extends Animal{
@Override
public
String
toString
()
{
public
String
toString
()
{
//forces all args to return a string data type(not really needed but a safety measure)
return
name
+
enviro
+
eats
+
noOfLegs
+
wings
+
Length
+
Description
;
}
}
InheritanceTest/src/inheritanceTest/Fish.java
View file @
84365613
...
...
@@ -2,17 +2,17 @@ package inheritanceTest;
public
class
Fish
extends
Animal
{
public
class
Fish
extends
Animal
{
//defines fish class as extension of animal
public
Fish
(
String
Name
,
String
habitat
,
String
food
,
String
legs
,
String
wingspan
,
String
length
,
String
Description
)
{
super
(
Name
,
habitat
,
food
,
legs
,
wingspan
,
length
,
Description
);
super
(
Name
,
habitat
,
food
,
legs
,
wingspan
,
length
,
Description
);
// provides arguments for fish type animal
}
@Override
public
String
toString
()
{
public
String
toString
()
{
//forces all args to return a string data type(not really needed but a safety measure)
return
name
+
enviro
+
eats
+
noOfLegs
+
wings
+
Length
+
Description
;
}
}
...
...
InheritanceTest/src/inheritanceTest/Mammal.java
View file @
84365613
package
inheritanceTest
;
public
class
Mammal
extends
Animal
{
public
class
Mammal
extends
Animal
{
//defines mammal class as extension of animal
public
Mammal
(
String
Name
,
String
habitat
,
String
food
,
String
legs
,
String
wings
,
String
length
,
String
Description
)
{
super
(
Name
,
habitat
,
food
,
legs
,
wings
,
length
,
Description
);
super
(
Name
,
habitat
,
food
,
legs
,
wings
,
length
,
Description
);
// provides arguments for mammal type animal
}
@Override
public
String
toString
()
{
public
String
toString
()
{
//forces all args to return a string data type(not really needed but a safety measure)
return
name
+
enviro
+
eats
+
noOfLegs
+
wings
+
Length
+
Description
;
}
...
...
InheritanceTest/src/inheritanceTest/Reptile.java
View file @
84365613
package
inheritanceTest
;
public
class
Reptile
extends
Animal
{
public
class
Reptile
extends
Animal
{
//defines reptile class as extension of animal
public
Reptile
(
String
Name
,
String
habitat
,
String
food
,
String
legs
,
String
wingspan
,
String
length
,
String
Description
)
{
super
(
Name
,
habitat
,
food
,
legs
,
wingspan
,
length
,
Description
);
super
(
Name
,
habitat
,
food
,
legs
,
wingspan
,
length
,
Description
);
// provides arguments for reptile type animal
}
@Override
public
String
toString
()
{
public
String
toString
()
{
//forces all args to return a string data type(not really needed but a safety measure)
return
name
+
enviro
+
eats
+
noOfLegs
+
wings
+
Length
+
Description
;
}
...
...
InheritanceTest/src/inheritanceTest/Test.java
View file @
84365613
This diff is collapsed.
Click to expand it.
InheritanceTest/src/inheritanceTest/test1.java
deleted
100644 → 0
View file @
8fec08e3
This diff is collapsed.
Click to expand it.
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