Created
May 25, 2017 14:20
-
-
Save peter279k/d1701a30c063066dc79719bcb0d63e52 to your computer and use it in GitHub Desktop.
TQC+ JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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