diff --git a/src/lab4/Furniture.java b/src/lab4/Furniture.java index f7ecea1..d8dce60 100644 --- a/src/lab4/Furniture.java +++ b/src/lab4/Furniture.java @@ -1,9 +1,11 @@ package lab4; -/** - * My class Furniture. - */ -public class Furniture { + +///** +// * My class Furniture. +// */ +//todo uncomment /**/ +public /*abstract*/ class Furniture/**/ implements Comparable/**/{ /** * */ @@ -13,11 +15,11 @@ public class Furniture { private int width; private int price; - private T additional; +// private T additional; - public void setAdditional(T additional) { - this.additional = additional; - } +// public void setAdditional(T additional) { +// this.additional = additional; +// } /** * @@ -74,4 +76,10 @@ public class Furniture { ", price=" + price + '}'; } + + @Override + public int compareTo(Object o) { + return /*this.*/price - ((Furniture) o).price; +// return /*this.*/material.compareTo(((Furniture) o).material); + } } diff --git a/src/lab4/Main.java b/src/lab4/Main.java index 67b3fb7..76c1ce9 100644 --- a/src/lab4/Main.java +++ b/src/lab4/Main.java @@ -4,11 +4,16 @@ import java.util.Arrays; public class Main { public static void main(String[] args) { + System.out.println(Integer.MIN_VALUE - 1); // todo Comparable //todo equals+hashcode // todo JavaDoc - final Furniture furniture1 = new Furniture<>("A", 1, 1, 1, 1); - final Furniture furniture2 = new Furniture<>("D", 1, 1, 1, 4); + final Furniture/**/ furniture1 = new Furniture("A", 1, 1, 1, 1); + final Furniture/**/ furniture2 = new Furniture("F", 1, 1, 1, 4); + + System.out.println(furniture1.compareTo(furniture2)); + System.out.println(furniture1.compareTo("furniture2")); + Furniture[] furnitureArray = { furniture1, furniture2, @@ -22,8 +27,8 @@ public class Main { } System.out.println("+++++++++++++"); - furniture1.setAdditional(new Furniture("Y", 1, 1, 1, 0)); - furniture2.setAdditional("new Furniture(\"Y\", 1, 1, 1, 0)"); +// furniture1.setAdditional(new Furniture("Y", 1, 1, 1, 0)); +// furniture2.setAdditional("new Furniture(\"Y\", 1, 1, 1, 0)"); // furnitureArray[0].setMaterial("E");