Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TQC+ JAVA
class SLuxCar extends Car {
public SLuxCar(int cc, String airMode) {
this.engine = new Engine(cc).getCost();
this.airCond = new Aircond(airMode).getCost();
this.carMode = "SLuxCar";
}
public String expensive(LuxCar lc) {
if(lc.price() < this.price()) {
return "Yes!!";
}
return "No!!";
}
}
public class JPA06_3 {
public static void main(String args[]) {
SLuxCar llc = new SLuxCar(2000,"Auto");
System.out.println("SLux cost: " + llc.cost());
System.out.println("SLux price: " + llc.price());
LuxCar lc = new LuxCar(2000,"Auto");
System.out.println("Is llc more expensive than lc? " + llc.expensive(lc));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.