Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- public class Item {
- private String name;
- private double weight;
- protected List<String> properties = new ArrayList<>();
- private boolean usable = false;
- public Item(String name, double weight) {
- this.name = name;
- this.weight = weight;
- }
- public Item(String name, double weight, String properties) {
- this.name = name;
- this.weight = weight;
- this.getProperties().add(properties);
- }
- public void getInfo() {
- System.out.printf("Название: %s\nВес: %sкг\n ", name, weight);
- System.out.println();
- }
- public void setUsable(boolean usable) {
- this.usable = usable;
- }
- public boolean isUsable() {
- return usable;
- }
- public List<String> getProperties() {
- return properties;
- }
- public double getWeight() {
- return weight;
- }
- public String getName() {
- return name;
- }
- public static void main(String[] args) {
- Item item = new Item("чет здоровое", 100000);
- item.getInfo();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement