Created
May 20, 2020 03:32
-
-
Save minor/041e098fb9bc69d2cfc06d1baae67d4f to your computer and use it in GitHub Desktop.
Shirt.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
package com.finalexam; | |
public class Clothing { | |
public int quantity; | |
public String color; | |
public Clothing() { | |
quantity = 0; | |
color = ""; | |
} | |
public Clothing(int quantity, String color) { | |
this.quantity = quantity; | |
this.color = color; | |
} | |
public int getQuantity() { | |
return quantity; | |
} | |
public void setQuantity(int quantity) { | |
this.quantity = quantity; | |
} | |
public String getColor() { | |
return color; | |
} | |
public void setColor(String color) { | |
this.color = color; | |
} | |
public double calculatePrice() { | |
return 0; | |
} | |
} |
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
package com.finalexam; | |
public class Pants extends Clothing { | |
public int waist; | |
public int inseam; | |
public Pants() { | |
waist = 0; | |
inseam = 0; | |
} | |
public Pants(int quantity, String color, int waist, int inseam) { | |
this.quantity = quantity; | |
this.color = color; | |
if (waist != 0) | |
this.waist = Math.abs(waist); | |
if (inseam != 0) | |
this.inseam = Math.abs(inseam); | |
} | |
public int getWaist() { | |
return waist; | |
} | |
public void setWaist(int waist) { | |
if (waist > 0) | |
this.waist = waist; | |
} | |
public int getInseam() { | |
return inseam; | |
} | |
public void setInseam(int inseam) { | |
if (inseam > 0) | |
this.inseam = inseam; | |
} | |
public double calculatePrice() { | |
if (waist < 48 && inseam < 36) | |
return 50.00; | |
else | |
return 65.50; | |
} | |
} |
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
package com.finalexam; | |
public class Shirt extends Clothing { | |
public String size; | |
public Shirt() { | |
size = ""; | |
} | |
public Shirt(int quantity, String color, String size) { | |
this.quantity = quantity; | |
this.color = color; | |
this.size = size; | |
} | |
public String getSize() { | |
return size; | |
} | |
public void setSize(String size) { | |
this.size = size; | |
} | |
public double calculatePrice() { | |
if (size.equals("S")) { | |
return 11; | |
} | |
else if (size.equals("M")) { | |
return 12.50; | |
} | |
else if (size.equals("L")) { | |
return 15; | |
} | |
else if (size.equals("XL")) { | |
return 16.50; | |
} | |
else { | |
return 18.50; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment