update lab4
This commit is contained in:
parent
eb2ffae473
commit
277f8f82f6
|
@ -1,9 +1,11 @@
|
|||
package lab4;
|
||||
|
||||
/**
|
||||
* My class Furniture.
|
||||
*/
|
||||
public class Furniture<T> {
|
||||
|
||||
///**
|
||||
// * My class Furniture.
|
||||
// */
|
||||
//todo uncomment /*<Furniture>*/
|
||||
public /*abstract*/ class Furniture/*<T>*/ implements Comparable/*<Furniture>*/{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -13,11 +15,11 @@ public class Furniture<T> {
|
|||
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<T> {
|
|||
", 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 static void main(String[] args) {
|
||||
System.out.println(Integer.MIN_VALUE - 1);
|
||||
// todo Comparable
|
||||
//todo equals+hashcode
|
||||
// todo JavaDoc
|
||||
final Furniture<Furniture> furniture1 = new Furniture<>("A", 1, 1, 1, 1);
|
||||
final Furniture<String> furniture2 = new Furniture<>("D", 1, 1, 1, 4);
|
||||
final Furniture/*<Furniture>*/ furniture1 = new Furniture("A", 1, 1, 1, 1);
|
||||
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 = {
|
||||
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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue