In addition to the way you have defined the needed constructors, you also need to define methods to determine the sale price, such as:
    public double getSalePrice() {
        if (length > 20)
          salePrice = regularPrice * 0.95;
        else
          salePrice = regularPrice * 0.90;
        return salePrice;

Then, you could determine the sale price of a Sedan, as follows:
    Sedan sedan1 = new Sedan (120, 25000.00, "red", 25);
    System.out.println ("Sedan's Sale Price:" + sedan1.getSalePrice());

Shawn Ayromloo



Rafał Laczek wrote:
Hi,
I have some problems with MyOwnShop class with the main() method.

In each class I have following constructors:

//Creates a new instance of Car
public Car(int speed, double regularPrice, String color ){
    this.speed=speed;
    this.regularPrice=regularPrice;
    this.color=color;
}


//Creates a new instance of Ford
    public Ford(int speed,double regularPrice, String color,
            int year, int manufacturerDiscount){
        super(speed, regularPrice, color);
        this.year=year;
        this.manufacturerDiscount=manufacturerDiscount;
    }

//Creates a new instance of Sedan
    public Sedan(int speed,double regularPrice, String color,
            int lenght){
        super(speed, regularPrice, color);
        this.lenght=lenght;
    }


Should I rebuild the project and put these constructors into 
MyOwnAutoShop class? but if these constructors should stay in current 
classes how I should initialize all fields with values and how to use 
super().
I have some  mish-mash  in my head with it.
 
Can somebody help me.

Thanks

Best regards,
Rafał Laczek

----------------------------------------------------
Marzysz o karierze modelki?
Przyjdź na Casting do konkursu ELITE MODEL LOOK.
I ty możesz zostać drugą Cindy Crawford!
Zobacz więcej: http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2Fmodelki_stopka.html&sid=661





  


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to