Mexi Liang 34b7eb7171 done | 6 gadus atpakaļ | |
---|---|---|
.DS_Store | 6 gadus atpakaļ | |
.gitignore | 6 gadus atpakaļ | |
Cat.java | 6 gadus atpakaļ | |
CatTest.java | 6 gadus atpakaļ | |
Dog.java | 6 gadus atpakaļ | |
DogTest.java | 6 gadus atpakaļ | |
Fish.java | 6 gadus atpakaļ | |
FishTest.java | 6 gadus atpakaļ | |
MainApplication.java | 6 gadus atpakaļ | |
MainApplicationTest.java | 6 gadus atpakaļ | |
Pet.java | 6 gadus atpakaļ | |
README.md | 6 gadus atpakaļ | |
package.bluej | 6 gadus atpakaļ |
In this lab you will practice creating a simple Java program designed to make use of polymorphic design.
Select a partner from your tribe; You will each write tests for the requirements below, but your partner must develop against your tests and vice versa.
Hint: An easy way to achieve this is for each partner to set up a Git.Zipcode.rocks repository for this lab, and add the other partner as a collaborator with write access (in the repository settings).
Create a program that asks the user how many pets they have. Once you know how many pets they have, ask them what kind of pet each one is, along with each pet's name. For now your program should just hold onto the user input and print out the list at the end; we'll modify this in part 3.
Create a Pet class, and a subclass for each type of pet that you want your program to support. Your classes should follow the following requirements:
speak
method that each subclass overrides.name
field with setters and getters.Use the tests provided as examples to write your own tests for other supported types of pets.
Modify your program from part 1 to use the Pet class and its subclasses. Keep a list of the pets your user lists and at the end of the program print out a list of their names and what they say when they speak.