you need to do the exercise like the instructions say...
its fairly straight forward once you realize that java cast everything
to the lowest type used,
which is 'int' in this case.
***all calculation values need to be type cast to double (the highest
used)
the discountprice goes in as an 'int' so you need to type cast the
values used to 'double'
remember - the discountprice is an 'int' not a percentage...
hint - devide by 100 to get the percentage (but your still not
done...)

On Feb 17, 2:24 pm, Raja Krishnamoorthy <[email protected]> wrote:
> Hi, I have a question on the Homework Exercise:
> one of the points says:
>
>    - Create a subclass of Car class and name it as Ford.  The Ford class has
>    the following fields and methods
>       - int year;
>       - int manufacturerDiscount;
>       - double getSalePrice();  // From the sale price computed from Car
>       class, subtract the manufacturerDiscount.
>
> The problem that I see with this exercise is that if Ford is a sub-class of
> Car, then we over0ride the method getSalePrice() in the Car class.
> Since Car is the super class, this method may return 0, since it can be
> overridden.
> So in the Ford sub class if I code the method as follows:
>     public double getSalePrice(){
>         return super.getSalePrice() - manufacturerDiscount;
>     }
>
> Then I will get a negative value for price.
>
> Should Ford be a sub-class of Truck class?
>
> Thanks
>
> Raja

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