Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 25, 2017 11:17
Show Gist options
  • Save peter279k/4a825f609ce7527d728e31d6a5e079f7 to your computer and use it in GitHub Desktop.
Save peter279k/4a825f609ce7527d728e31d6a5e079f7 to your computer and use it in GitHub Desktop.
TQC+ JAVA
class Base {
public int cost = 0;
public int getCost() {
return this.cost;
}
}
class Engine extends Base {
public Engine(int cc) {
if(cc == 1600) {
this.cost = 20000;
} else {
this.cost = 25000;
}
}
}
class Aircond extends Base {
public Aircond(String mode) {
if(mode.equals("Auto")) {
this.cost = 12000;
} else {
this.cost = 10000;
}
}
}
class Sound extends Base {
public Sound() {
this.cost = 2000;
}
}
public class JPA06_1 {
public static void main(String args[]){
Engine e1 = new Engine(1600);
System.out.println("1600 cost: " + e1.getCost());
Engine e2 = new Engine(2000);
System.out.println("2000 cost: " + e2.getCost());
Aircond a1 = new Aircond("Auto");
System.out.println("Auto: " + a1.getCost());
Aircond a2 = new Aircond("Manual");
System.out.println("Manual: " + a2.getCost());
Sound s1 = new Sound();
System.out.println("Sound: " + s1.getCost());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment