ICS 111, In-Class Assignment 17 Assigned on 11/12 is due 5 pm on

advertisement
ICS 111, In-Class Assignment 17
Assigned on 11/12 is due 5 pm on 11/19/2015
Startup
last
Launch Eclipse and create a new project named CA17_LF where LF is your
and then your
first name. For example, if your name is Hungry Leopard then your project name will be
CA17_LeopardHungry.
Programming: Implement and test the following inheritance hierarchy of classes shown in the Figure 1
below. Figure 1 also shows the methods that you must implement in each class.
IMPORTANT - It is critical that you perform the steps 1-4 in the order presented. Failure to do so more
than likely will result in more time spent on this project.
1.
Implement each of the ten classes shown above in Figure 1 with the appropriate inheritance
structure.
A.
Each class should be in its own file; therefore, you will have 10 class files: Animal.java,
Bird.java, Parrot.java, Reptile.java, Snake.java, Mammal.java, Feline.Java, Leopard.java,
Cat.java, and Bat.java.
B.
Remember that for a class to have inheritance, you must extend to the immediate superclass.
C.
IMPORTANT, assume at this point that you have 10 empty classes (i.e., no data fields, no
constructors, and no methods).
D.
Place a Java comment as the first line on all 10 files that includes your first and last names.
Failure to do so will result in a deduction of points. .
Compile and remove all errors. Compiling in Eclipse means that there are NO red marks to the
left of each Java statement.
2.
Implement the data fields and methods according to the instructions below for all the classes except
the Snake, Mammal, and Cat classes. You are required to used the appropriate type declarations
and visibility modifiers. The constructor methods are NOT included in this step.
Animal class
Data Field:
Methods:
name is a private string that represents the animal’s name.
getName()
– returns the animal’s name
move()
– returns “name moves”
Replace name above with the actual name of the animal.
Compile the Animal class and remove all errors before proceeding with the next class.
Bird class
Data Field:
color is a private string that represents the bird’s color.
Methods:
getColor()
–returns the bird’s color.
Compile the Bird class and remove all errors before proceeding with the next class.
Parrot class
Methods:
move() overrides the inherited move() method from the parent class and
returns a string “name moves by flying in circles.” The name is the Parrot’s
name.
This method must call the inherited method move() to
generate “name moves”
Compile the Parrot class and remove all errors before proceeding with the next class.
Reptile class
Methods:
move() overrides the inherited move() method from the parent class and
returns a string “name moves left to right.” The name is the Reptiles’s name.
This method must call the inherited method move() to
generate “name moves”
Compile the Reptile class and remove all errors before proceeding with the next class.
Feline class
Methods:
move() overrides the inherited move() method from the parent class and
returns a string “name moves by pouncing” The name is the Feline’s name.
This method must call the inherited method move() to
generate “name moves”
Compile the Feline class and remove all errors before proceeding with the next class.
Leopard class
Methods
move() overrides the inherited move() method from the parent class and
returns a string “name moves by pouncing on fried chicken” The name is the
Leopard’s name.
This method must call the inherited method move() to
generate “name moves by pouncing”
Compile the Leopard class and remove all errors before proceeding with the next class.
Bat class
Methods:
move() overrides the inherited move() method from the parent class and
returns a string “name moves by flapping wings in the dark.” The name is
the Bat’s name.
This method must call the inherited method move() to
generate “name moves”
Compile the Bat class and remove all errors before proceeding with the next class.
There should be no compilation errors at this point.
3.
Implement constructor methods for all classes listed below.
Use super to invoke the appropriate parent’s constructor method to set the name.
Animal class
Animal ()
The data field name is initialized to “Who am I?”
Animal(String name)
The data field name is initialized to the parameter name.
Compile the Animal class and remove all errors before proceeding with the next class.
Bird Class
Bird ()
The data field name is initialized to “Sharp eyes”
Bird (String name)
The data field name is initialized to the parameter name.
Compile the Bird class and remove all errors before proceeding with the next class.
Parrot Class
Parrot()
The data field name is initialized to “Polly”
Parrot (String name)
The data field name is initialized to the parameter name.
Compile the Parrot class and remove all errors before proceeding with the next class.
Reptile Class
Reptile ()
The data field name is initialized to “Leather skin”
Reptile (String name)
The data field name is initialized to the parameter name.
Compile the Reptile class and remove all errors before proceeding with the next class.
Snake Class
Snake ()
The data field name is initialized to “Slither”
Snake (String name)
The data field name is initialized to the parameter name.
Compile the Snake class and remove all errors before proceeding with the next class.
Mammal class
Mammal()
The data field name is initialized to “Big foot”
Mammal(String name)
The data field name is initialized to the parameter name.
Compile the Mammal class and remove all errors before proceeding with the next class.
Feline class
Feline()
The data field name is initialized to “Curious me”
Feline(String name)
The data field name is initialized to the parameter name.
Compile the Feline class and remove all errors before proceeding with the next class.
Bat class
Bat()
The data field name is initialized to “Vampire Bat”
Bat(String name)
The data field name is initialized to the parameter name.
Compile the Bat class and remove all errors.
Leopard class
Leopard()
The data field name is initialized to “Tree climber”
Leopard(String name)
The data field name is initialized to the parameter name.
Compile the Leopard class and remove all errors before proceeding with the next class.
Cat class
Cat()
The data field name is initialized to “Small cat”
Cat(String name)
The data field name is initialized to the parameter name.
Compile the Cat class and remove all errors before proceeding with the next class.
There should be no compilation errors at this point.
4.
Create an application class called AnimalApplication. Therefore, the name of your Java source file
will be AnimalApplication.java. In addition, place a Java comment that includes your first and
last names on the first line of the AnimalApplication.
Do the following steps for this application class.
A.
Create the following the following 10 Animal objects in the order presented.
Animal object with the name “Giant Short Face Bear”
Bird object with the name “Tweety”
Parrot object with the name “Hungry Chicken”
Reptile object with the name “Snagosaurus”
Snake object with the name “Viper”
Mammal object with the name “Giant Bear”
Feline object with the name “Fast Feet”
Leopard object with the name “Sabertooth”
Cat object with the name “Tiger Cat”
Bat object with the name “Fruit Eater”
Compile and remove all errors before proceeding with the next step.
B.
Output the result of calling move() method of each of the objects in part A.
Delivery of In-Class Assignment to the Starlite FTP Server
1.
Assuming that you have successfully compiled and tested your program files and classes, zip your
project folder CA17_LF .
a.
Use Windows Explorer to navigate to and open your workspace folder.
b.
Right-click folder CA17_LF ÿ Send to ÿ Compressed (zipped) folder
The compressed folder will be named CA17_LF.zip
Do not proceed to step 2 unless step 1.b has been completed.
2.
3.
After compressing the folder in step 1b, launch FileZilla, log in using your class account, and make
a connection to the Starlite FTP Server.
Send and verify the delivery of your zip file.
a.
In the local site, navigate to CA17_LF.zip.
b.
Right click on CA17_LF.zip and click on Upload.
c.
Check the Successful transfer tab to verify that CA17_LF.zip was uploaded successfully
inside the 111 folder at the Starfire FTP Server.
Download