public class ShirtTest {
public static void main(String[] args) {
Shirt shirt1 = new Shirt();
shirt1.setName("new name");
shirt1.setBid(23.5);
shirt1.setSize(Size.M);
System.out.println(shirt1);
}
}
class Shirt {
private String name;
private double bid;
private Size size;
public Shirt() {
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setBid(double bid) {
this.bid = bid;
}
public double getBid() {
return bid;
}
public void setSize(Size size) {
this.size = size;
}
public Size getSize() {
return size;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(" Name: " + this.getName() + ",");
sb.append(" Bid: " + this.getBid() + " Dollar,");
sb.append(" Size: " + this.getSize());
return sb.toString();
}
}
enum Size {
S, M, L, XL, XXL, XXXL;
}
|