Advertisement
Guest User

type 3

a guest
Jan 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. public interface Clothes {
  2.  
  3. float Costprice () ;
  4. }
  5. public class Jacket implements Clothes {
  6.  
  7. private String manufacturer, style;
  8. protected int hours;
  9. private String season;
  10. private boolean hood;
  11.  
  12. public Jacket(String manufacturer, String style, int hours, String season, boolean hood) {
  13. this.manufacturer = manufacturer;
  14. this.style = style;
  15. this.hours = hours;
  16. this.season = season;
  17. this.hood = hood;
  18. }
  19.  
  20. public float Costprice() {
  21. return hours * 3;
  22. }
  23. }
  24. public class Windcheater extends Jacket {
  25.  
  26. private int sleevelength;
  27.  
  28. public Windcheater(String manufacturer, String style, int hours, String season, boolean hood, int sleevelength) {
  29. super(manufacturer, style, hours, season, hood);
  30. this.sleevelength = sleevelength;
  31. }
  32.  
  33. public float Costprice() {
  34. return hours * 2;
  35. }
  36. }
  37. public class Main {
  38. public static void main(String[] args) {
  39.  
  40. Windcheater windcheater[] = new Windcheater[5];
  41. for(int i = 0; i < 5; i++) {
  42. windcheater[0] = new Windcheater("Nike", "casual", 2, "spring", true, 67);
  43. windcheater[1] = new Windcheater("Adidas", "casual", 3, "fall", false, 65);
  44. windcheater[2] = new Windcheater("Nike", "casual", 1, "spring", true, 70);
  45. windcheater[3] = new Windcheater("Puma", "casual", 3, "winter", true, 68);
  46. windcheater[4] = new Windcheater("New Balance", "casual", 2, "fall", true, 67);
  47. }
  48. float costpriceAll = (windcheater[0].Costprice() + windcheater[1].Costprice() + windcheater[2].Costprice() + windcheater[3].Costprice() +
  49. windcheater[4].Costprice()) / 5;
  50.  
  51. System.out.println(costpriceAll);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement