-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClothing.java
63 lines (62 loc) · 1.49 KB
/
Clothing.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
/*
* Created by Noah Shaw
*/
public class Clothing {
//Instance variables
private String type;
private String color;
//Constructors
public Clothing()
{
this.type = "";
this.color = "";
}
public Clothing(String aType, String aColor)
{
this.setType(aType);
this.setColor(aColor);
}
//Accessors
public String getType()
{
return this.type;
}
public String getColor()
{
return this.color;
}
//Mutators
public void setType(String aType)
{
if(aType.equalsIgnoreCase("Undergarment") || aType.equalsIgnoreCase("Socks") || aType.equalsIgnoreCase("Stockings") || aType.equalsIgnoreCase("Top") || aType.equalsIgnoreCase("Bottom") || aType.equalsIgnoreCase("Cape"))
{
this.type = aType;
}
else
{
System.out.println("Invalid type.");
}
}
public void setColor(String aColor)
{
if(aColor.equalsIgnoreCase("Brown") || aColor.equalsIgnoreCase("Red") || aColor.equalsIgnoreCase("Pink") || aColor.equalsIgnoreCase("Orange") || aColor.equalsIgnoreCase("Green") || aColor.equalsIgnoreCase("Blue") || aColor.equalsIgnoreCase("Purple") || aColor.equalsIgnoreCase("Grey"))
{
this.color = aColor;
}
else
{
System.out.println("Invalid color.");
}
}
//Methods
public String toString()
{
return "Type: "+this.type+" Color: "+this.color;
}
public boolean equals(Clothing aClothing)
{
return aClothing != null &&
this.type.equals(aClothing.getType()) &&
this.color.equals(aClothing.getColor());
}
}