Question: In Exercise 10, above, indicate all changes you would make to Pet2, Cat2, and Dog2 so that Pet2 is an interface rather than an abstract

In Exercise 10, above, indicate all changes you would make to Pet2, Cat2, and Dog2 so that Pet2 is an interface rather than an abstract class. It should not be necessary to make any changes to Exercise 10’s Pet2Driver class.

Exercise 10

Given the Pet2Driver class below, write an abstract Pet2 class that contains just one item—an abstract declaration for a speak method. Also write Dog2 and Cat2 classes that extend Pet2, so that when you execute Pet2Driver and input ‘c’ or ‘d’, the program prints “Meow! Meow!” or “Woof! Woof” but if you input anything else, it does not print anything.

/*** *Hourly.java *Dean & Dean * * This class implements an employee paid by the hour. *** ***/ public class

/*** *Hourly.java *Dean & Dean * * This class implements an employee paid by the hour. *** ***/ public class Hourly extends Employee { private double hourly Rate; private double hours = 0.0; //************ super (name); hourly Rate = rate; } // end constructor public Hourly (String name, double rate) { //************************************************* @Override public double getPay ( ) ( // Postcondition: This resets hours to zero. ************* ****************** double pay = hourly Rate * hours; hours 0.0; return pay; 3 // end getPay //******** public void addHours (double hours) { this.hours += hours; } // end addHours. } // end class Hourly ********

Step by Step Solution

3.46 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on your question youre looking for guidance on how to modify classes so that Pet2 is implemented as an interface instead of an abstract class an... View full answer

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 Introduction To Programming With Java A Problem Solving Approach Questions!