Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 25, 2017 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter279k/d1701a30c063066dc79719bcb0d63e52 to your computer and use it in GitHub Desktop.
Save peter279k/d1701a30c063066dc79719bcb0d63e52 to your computer and use it in GitHub Desktop.
TQC+ JAVA
class PC extends Base {
public PC() {
this.cost = new CPU(2.4).getCost() + new HD("160G").getCost() + 500;
this.price = (new CPU(2.4).getCost() + new HD("160G").getCost()) * 1.8;
}
}
class MultiPC extends Base {
public MultiPC(int num, int num2) {
this.cost = (new CPU(2.4).getCost() * num + new HD("160G").getCost() * num2) * 1.2;
this.price = (new CPU(2.4).getCost() * num + new HD("160G").getCost() * num2) * 1.8;
}
}
class JPA06_2 {
public static void main(String args[]){
PC pc = new PC();
System.out.println("PC cost:"+pc.getCost()+", price:"+pc.getPrice());
MultiPC multipc1 = new MultiPC(2, 4);
System.out.println("MultiPC: 2CPU, 4HD, cost:"+multipc1.getCost()+", price:"+multipc1.getPrice());
MultiPC multipc2 = new MultiPC(4, 8);
System.out.println("MultiPC: 4CPU, 8HD, cost:"+multipc2.getCost()+", price:"+multipc2.getPrice());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment