Question: Interface Exercise Given the following UML Class diagram, answer the questions listed below. Notice that DomesticAnimal is an interface, Pet is an abstract class and

 Interface Exercise Given the following UML Class diagram, answer the questions

Interface Exercise Given the following UML Class diagram, answer the questions listed below. Notice that DomesticAnimal is an interface, Pet is an abstract class and adoption Completed is an abstract method. Owner -name:String +Owner (name:String) +getName():String 1 1 Q1. Create the above class hierarchy in Java. Having done so, create a test harness/application/run class named ShelterRun. Pet Q2. Create an owner named "Jack Black" #age:int #breed:String #owner Owner +Pet (breed:String, age:int) +getAge():int +getBreed():String +birthday () //increase +age by one +adoption Completed() // print +dog.name is adopted by the +owner.name +setOwner(o:Owner) +getOwner Name ():String Q3. Inside Shelter run, create a dog named "Max", that is a Golden Retriever and 5 years old. Set Max's owner as "Jack Black" and invoke the adoptionCompleted() method. Q4. Max loves to eat "dog biscuits" and sleeps 7 hours per day. Q5. As today is the birthday of Max, invoke the birthday method. Having done so, make sure Max runs from home to the park. Q6. Display max features as follows in a JOptionPane.showMessageDialog: Dog name = Max Dog breed = Golden Retriever Dog age = 6 Owner = Jack Black OK > DomesticAnimal Dog -name:String +Dog(b:String, a:int) +getName():String +setName(n:String) +isDomesticated:boolean = true +move(from:String, to:String):void // print "runs from to +to +eat(food:String):void // print eats #food +sleep(hours:int):void // sleeps thours hours per day

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!