Why don't you try it with this.getSalePrice() instead of super.getSalePrice()?
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 -~----------~----~----~----~------~----~------~--~---
