Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * 1. Make Dragon inherit all the Animal fields and methods using the proper Java keyword.
- * 1. Add these fields to this class:
- * boolean isCastleBroken
- * String name
- * 2. Create the getters and setters for those 2 fields
- * 3. Create a no-arg constructor that sets those fields to false and "unnamed" by default.
- * 4. Create a constructor that takes in two parameters to set those fields to values.
- */
- public class Dragon {
- Animal Dragon = new Animal();
- //data fields or properties
- private String name;
- boolean isCastleBroken;
- private String animalName;
- //No-arg constructor
- Dragon() {
- name = "NA";
- isCastleBroken = false;
- }
- //Constructor
- Dragon(String dragon, String animal) {
- name = dragon;
- animalName = animal;
- }
- //Setters
- public void setDragonName(String dragon) {
- name = dragon;
- }
- //Getters
- public String getDragonName() {
- return name;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement