/
Item.java
110 lines (101 loc) · 1.78 KB
/
Item.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import java.util.*;
import java.util.ArrayList;
import java.io.*;
public class Item {
private int x;
private int y;
private boolean isCarried;
private String color;
private String shape;
//private boolean edibility, heaviness;
public Item(int a, int b, int newcolor, int newshape){
x=a;
y=b;
isCarried = false;
if (newcolor == 0){
color = "red";
}else if(newcolor == 1){
color = "orange";
}else if(newcolor == 2){
color = "yellow";
}else if(newcolor == 3){
color = "green";
}else if(newcolor == 4){
color = "blue";
}else if(newcolor == 5){
color = "lightblue";
}else if(newcolor == 6){
color = "purple";
}else if(newcolor == 7){
color = "pink";
}else if(newcolor == 8){
color = "brown";
}else if(newcolor == 9){
color = "gray";
}else if(newcolor == 10){
color = "black";
}
if(newshape == 0){
shape = "circle";
}else if(newshape == 1){
shape = "moon";
}else if(newshape == 2){
shape = "square";
}else if(newshape == 3){
shape = "star";
}else if(newshape == 4){
shape = "triangle";
}
}
public Item(int a, int b, String c, String s)
{
x = a;
y = b;
isCarried = false;
color = c;
shape = s;
}
public String getColor()
{
return color;
}
public String getShape()
{
return shape;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public boolean setX(int a)
{
x = a;
return true;
}
public boolean setY(int b)
{
y = b;
return true;
}
public boolean setCarried(boolean b)
{
isCarried = b;
return true;
}
public boolean equals(Item thing)
{
if (!color.equals(thing.getColor()))
return false;
if (!shape.equals(thing.getShape()))
return false;
return true;
}
public String toString()
{
return "" + color + " " + shape;
}
}