Advertisement
Guest User

type 1

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