Created
May 25, 2017 13:37
-
-
Save peter279k/472013a19d058539cafd36a93d0fa547 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 Base { | |
public double cost = 0.0; | |
public double price = 0.0; | |
public double getCost() { | |
return this.cost; | |
} | |
public double getPrice() { | |
return this.price; | |
} | |
} | |
class LCD extends Base { | |
public LCD(int size) { | |
if(size == 10) { | |
this.cost = (double)2000; | |
} | |
if(size == 15) { | |
this.cost = (double)2500; | |
} | |
if(size == 17) { | |
this.cost = (double)3000; | |
} | |
} | |
} | |
class CPU extends Base { | |
public CPU(double speed) { | |
if(speed == 1.66) { | |
this.cost = (double)6000; | |
} | |
if(speed == 2.2) { | |
this.cost = (double)8000; | |
} | |
if(speed == 2.4) { | |
this.cost = (double)11000; | |
} | |
} | |
} | |
class HD extends Base { | |
public HD(String size) { | |
if(size.equals("120G")) { | |
this.cost = (double)2400; | |
} | |
if(size.equals("160G")) { | |
this.cost = (double)2800; | |
} | |
} | |
} | |
class MiniNote extends Base { | |
public MiniNote() { | |
this.cost = (double)(new LCD(10).getCost() + new CPU(1.66).getCost() + new HD("120G").getCost()) * (double)1.4; | |
this.price = (double)(new LCD(10).getCost() + new CPU(1.66).getCost() + new HD("120G").getCost()) * (double)2; | |
} | |
} | |
class Note15 extends Base { | |
public Note15() { | |
this.cost = (double)(new LCD(15).getCost() + new CPU(2.2).getCost() + new HD("160G").getCost()) * (double)1.4; | |
this.price = (double)(new LCD(15).getCost() + new CPU(2.2).getCost() + new HD("160G").getCost()) * (double)2; | |
} | |
} | |
class JPA06_1 { | |
public static void main(String args[]){ | |
MiniNote mininote = new MiniNote(); | |
System.out.println("MiniNote cost:"+mininote.getCost()+", price:"+mininote.getPrice()); | |
Note15 note15 = new Note15(); | |
System.out.println("Note15 cost:"+note15.getCost()+", price:"+note15.getPrice()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment