Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface Clothes {
- float Costprice () ;
- }
- public class Jacket implements Clothes {
- private String manufacturer, style;
- protected int hours;
- private String season;
- private boolean hood;
- public Jacket(String manufacturer, String style, int hours, String season, boolean hood) {
- this.manufacturer = manufacturer;
- this.style = style;
- this.hours = hours;
- this.season = season;
- this.hood = hood;
- }
- public float Costprice() {
- return hours * 3;
- }
- }
- public class Windcheater extends Jacket {
- private int sleevelength;
- public Windcheater(String manufacturer, String style, int hours, String season, boolean hood, int sleevelength) {
- super(manufacturer, style, hours, season, hood);
- this.sleevelength = sleevelength;
- }
- public float Costprice() {
- return hours * 2;
- }
- }
- public class Main {
- public static void main(String[] args) {
- Windcheater windcheater[] = new Windcheater[5];
- for(int i = 0; i < 5; i++) {
- windcheater[0] = new Windcheater("Nike", "casual", 2, "spring", true, 67);
- windcheater[1] = new Windcheater("Adidas", "casual", 3, "fall", false, 65);
- windcheater[2] = new Windcheater("Nike", "casual", 1, "spring", true, 70);
- windcheater[3] = new Windcheater("Puma", "casual", 3, "winter", true, 68);
- windcheater[4] = new Windcheater("New Balance", "casual", 2, "fall", true, 67);
- }
- float costpriceAll = (windcheater[0].Costprice() + windcheater[1].Costprice() + windcheater[2].Costprice() + windcheater[3].Costprice() +
- windcheater[4].Costprice()) / 5;
- System.out.println(costpriceAll);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement