update lab4
This commit is contained in:
parent
eb2ffae473
commit
277f8f82f6
|
@ -1,9 +1,11 @@
|
||||||
package lab4;
|
package lab4;
|
||||||
|
|
||||||
/**
|
|
||||||
* My class Furniture.
|
///**
|
||||||
*/
|
// * My class Furniture.
|
||||||
public class Furniture<T> {
|
// */
|
||||||
|
//todo uncomment /*<Furniture>*/
|
||||||
|
public /*abstract*/ class Furniture/*<T>*/ implements Comparable/*<Furniture>*/{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -13,11 +15,11 @@ public class Furniture<T> {
|
||||||
private int width;
|
private int width;
|
||||||
private int price;
|
private int price;
|
||||||
|
|
||||||
private T additional;
|
// private T additional;
|
||||||
|
|
||||||
public void setAdditional(T additional) {
|
// public void setAdditional(T additional) {
|
||||||
this.additional = additional;
|
// this.additional = additional;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -74,4 +76,10 @@ public class Furniture<T> {
|
||||||
", price=" + price +
|
", price=" + price +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Object o) {
|
||||||
|
return /*this.*/price - ((Furniture) o).price;
|
||||||
|
// return /*this.*/material.compareTo(((Furniture) o).material);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,16 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
System.out.println(Integer.MIN_VALUE - 1);
|
||||||
// todo Comparable
|
// todo Comparable
|
||||||
//todo equals+hashcode
|
//todo equals+hashcode
|
||||||
// todo JavaDoc
|
// todo JavaDoc
|
||||||
final Furniture<Furniture> furniture1 = new Furniture<>("A", 1, 1, 1, 1);
|
final Furniture/*<Furniture>*/ furniture1 = new Furniture("A", 1, 1, 1, 1);
|
||||||
final Furniture<String> furniture2 = new Furniture<>("D", 1, 1, 1, 4);
|
final Furniture/*<String>*/ furniture2 = new Furniture("F", 1, 1, 1, 4);
|
||||||
|
|
||||||
|
System.out.println(furniture1.compareTo(furniture2));
|
||||||
|
System.out.println(furniture1.compareTo("furniture2"));
|
||||||
|
|
||||||
Furniture[] furnitureArray = {
|
Furniture[] furnitureArray = {
|
||||||
furniture1,
|
furniture1,
|
||||||
furniture2,
|
furniture2,
|
||||||
|
@ -22,8 +27,8 @@ public class Main {
|
||||||
}
|
}
|
||||||
System.out.println("+++++++++++++");
|
System.out.println("+++++++++++++");
|
||||||
|
|
||||||
furniture1.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)");
|
// furniture2.setAdditional("new Furniture(\"Y\", 1, 1, 1, 0)");
|
||||||
|
|
||||||
// furnitureArray[0].setMaterial("E");
|
// furnitureArray[0].setMaterial("E");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue