Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.homework11;
- import java.util.ArrayList;
- import java.util.List;
- public class TaskThree {
- public static void main(String[] args) {
- List<Box> box = new ArrayList<>();
- box.add(new Box( new Orange(15,3)));
- box.add(new Box(new Apple(13, 4)));
- box.add(new Box(new Orange(17, 2)));
- box.add(new Box(new Orange(13, 1)));
- box.add(new Box(new Apple(8, 3)));
- box.get(0).
- }
- }
- package com.homework11;
- public class Box <T>{
- T typeNameFruit;
- public Box(T typeNameFruit) {
- this.typeNameFruit = typeNameFruit;
- }
- //получаем вес коробки
- public int getWeight(T obj) {
- return 0;
- }
- //сравниваем коробки
- public boolean compare(T obj) {
- return false;
- }
- }
- package com.homework11;
- public class Fruit {
- private Integer quantityFruit;
- private Integer weightFruit;
- public Integer getWeightFruit() {
- return 0;
- }
- public Integer getQuantityFruit() {
- return quantityFruit;
- }
- public Fruit(Integer quantityFruit, Integer weightFruit) {
- this.quantityFruit = quantityFruit;
- this.weightFruit = weightFruit;
- }
- }
- package com.homework11;
- public class Apple extends Fruit {
- public String id = "testVariable";
- public Apple(Integer quantityFruit, Integer weightFruit) {
- super(quantityFruit, weightFruit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement