Richard:
First, you have to understand what Polymorphism is. In a nut shell
you have a super class, like Dog which has methods for eating, barking
and wagging its tail. You make another class which extends dog ie
class GermanShepard extends Dog
now polymorphism is that GermanShepard can have it's own method of
PlayingWithBall(), and it can use the methods from Dog, ie Bark(),
Eat(), or WagTail() when they are overridden. So now, Dog has a
constructor with 3 parameters, and GermanShepard has a constructor
with four parameters. The let's say you have an instance of Dog and an
instance of GermanShepard. Polymorphism means that the Object
determines which type it is and therefore which method it calls, the
base method or the overridden method.
Therefore the homework is to modify the MyOwnAutoShopProject so that:
First, you make interfaces for each of the sub-classes of car
Car is your super, so Ford is a sub-class
Your interface for Ford has it's own method statement which will be
defined in the Class Ford,
ie
class Ford extends Car implements FordInterface()
when you have this, Ford not only has it's own method of getWeight and
setWeight but it now can use the methods of Car
getSpeed, setSpeed, getRegularPrice, setRegularPrice, all of which are
now also methods of Ford, overridden. So, the constructor for an
Instance of Car would be
public Car(int speed, double regularPrice, String color, double
getSalePrice){...your code}
and for Ford it would be
public Ford(int speed, double regularPrice, String color, double
getSalePrice, int year, int manufacturerDiscount){...your code}
then the Object called determines which regularPrice method to use.
now class Ford can be by itself or much more dynamic in that it can
extends Car, and you don't have to worry about which of the
regularPrice methods it is going to use, the Object itself will
determine that. Hope that points you in the right direction.
Jeffrey
On Oct 26, 11:48 am, Richard <[EMAIL PROTECTED]> wrote:
> Hi,
> the description for the homework says "The homework is to modify the
> MyOwnAutoShopProject you did as LAB-1023: Java Inheritance homework to
> use Java interface. Here I am going to call the new project
> MyOwnAutoShopUsingInterface.
> * The task you will have to do is something similar to the
> MyOnlineShopUsingInterface project above."
>
> I'm not sure what it is that we are supposed to do.
>
> Can anyone provide some more details?
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---