Advertisement
rex897

public class Item

Nov 4th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3.  
  4. public class Item {
  5.     private String name;
  6.     private double weight;
  7.     protected List<String> properties = new ArrayList<>();
  8.     private boolean usable = false;
  9.  
  10.     public Item(String name, double weight) {
  11.         this.name = name;
  12.         this.weight = weight;
  13.     }
  14.  
  15.     public Item(String name, double weight, String properties) {
  16.         this.name = name;
  17.         this.weight = weight;
  18.         this.getProperties().add(properties);
  19.     }
  20.  
  21.     public void getInfo() {
  22.         System.out.printf("Название: %s\nВес: %sкг\n ", name, weight);
  23.         System.out.println();
  24.     }
  25.  
  26.     public void setUsable(boolean usable) {
  27.         this.usable = usable;
  28.     }
  29.  
  30.     public boolean isUsable() {
  31.         return usable;
  32.     }
  33.  
  34.     public List<String> getProperties() {
  35.         return properties;
  36.     }
  37.  
  38.     public double getWeight() {
  39.         return weight;
  40.     }
  41.  
  42.     public String getName() {
  43.         return name;
  44.     }
  45.  
  46.     public static void main(String[] args) {
  47.         Item item = new Item("чет здоровое", 100000);
  48.         item.getInfo();
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement