what is the problem in this i got only zero for ans plz explain?
the overriding method getSalePrice() is not also working what is the
reason?
MAIN CLASS
package myownautoshopproject;
public class Main {
public static void main(String[] args) {
car car1=new car();
car1.setSpeed(240);
car1.setColor("Red");
car1.setRegularPrice(10000);
Sedan sedan=new Sedan();
sedan.setLength=(25);
Truck truck=new Truck();
truck.setWeight=(2200);
Ford ford=new Ford();
ford.setYear(2009);
ford.setmanufacturerDiscount(2000);
System.out.println("regular price of car:"+car1.getRegularPrice
());
System.out.println("speed of car:"+car1.getspeed());
System.out.println("sale price sedan:"+sedan.getSalePrice());
System.out.println("sale price of Ford:"+ford.getSalePrice());
System.out.println("sale price of Truck:"+truck.getSalePrice
());
}
CAR CLASS
package myownautoshopproject;
public class car {
private int speed;
private double SalePrice;
private String color;
private double regularPrice;
public double getSalePrice(){
return 0;
}
public int getspeed(){
return speed;
}
public void setSpeed(int speed){
this.speed=speed;
}
public String getcolor(){
return color;
}
public void setColor(String color){
this.color=color;
}
public double getRegularPrice() {
return regularPrice;
}
public void setRegularPrice(double regularPrice) {
this.regularPrice = regularPrice;
}
}
SEDAN CLASS
package myownautoshopproject;
public class Sedan extends car {
public int length;
int setLength;
public double getSalePrice(){
if(length>20){
return super.getRegularPrice()*0.05;
}
else
return super.getRegularPrice()*0.1;
}
public int getLength(){
return length;
}
package myownautoshopproject;
public class Truck extends car {
private double weight;
int setWeight;
public double getSalePrice(){
if(weight>2000){
return super.getRegularPrice()*0.1;
}
else
return super.getRegularPrice()*0.5;
}
public double getWeight(){
return weight;
}
public void setWeignt(double weight){
this.weight=weight;
}
}
TRUCK CLASS
package myownautoshopproject;
public class Truck extends car {
private double weight;
int setWeight;
public double getSalePrice(){
if(weight>2000){
return super.getRegularPrice()*0.1;
}
else
return super.getRegularPrice()*0.5;
}
public double getWeight(){
return weight;
}
public void setWeignt(double weight){
this.weight=weight;
}
}
public void setLength(int length){
this.length=length;
}
}
}
FORD CLASS
package myownautoshopproject;
public class Ford extends car {
public int year;
public double manufacturerDiscount;
public double getSalePrice(){
return (super.getRegularPrice()-ford.getmanufacturerDiscount
());
}
public int getYear(){
return year;
}
public void setYear(int year){
this.year=year;
}
public double getmanufacturerDiscount(){
return manufacturerDiscount;
}
public void setmanufacturerDiscount(double manufacturerDiscount){
this.manufacturerDiscount=manufacturerDiscount;
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---