Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //parreira
- public class HardDrive {
- //const
- private static final int TAMANHOGB = 1024;
- private static final int ESCALAO1 = 150;
- private static final float TAXA1 = 0.02f;
- private static final float TAXA2 = 0.005f;
- //var
- private int serial;
- private String provider;
- private int capacity;
- private float basePrice;
- public HardDrive(int serial, String provider, int capacity, float basePrice) {
- this.serial = serial;
- this.provider = provider;
- this.capacity = capacity;
- this.basePrice = basePrice;
- }
- public int getSerialNumber() {
- return serial;
- }
- public String getProvider() {
- return provider;
- }
- public float getBasePrice() {
- return basePrice;
- }
- public int getCapacity() {
- return capacity;
- }
- public void setNewBasePrice(float newBasePrice) {
- basePrice = newBasePrice;
- }
- public float getTax() {
- float tax = 0;
- if (getCapacity() > TAMANHOGB)
- tax = ( getCapacity() - TAMANHOGB) * TAXA2 + TAMANHOGB * TAXA1;
- if (getCapacity() >= ESCALAO1)
- tax = getCapacity() * TAXA1;
- return tax;
- }
- public boolean lessExpensiveThan(HardDrive other) {
- float preco = (getBasePrice() + getTax()) / getCapacity();
- float precoOther = (other.getBasePrice() + other.getTax()) / other.getCapacity();
- boolean maisBarato = false;
- if (preco > precoOther)
- maisBarato = true;
- return maisBarato;
- }
- }
Add Comment
Please, Sign In to add comment