Design Clothing store using OOP concepts. based on your design tell how you'll find if the store has XXL size of a particular shirt.
package
OOP.clothstore;
import
java.util.ArrayList;
import
java.util.Hashtable;
class
cloth{
String brand;
String barCode;
Type type;
Size size;
enum
Size{xs,s,m,l,xl,xxl};
enum
Type{Tshirt, hoodie, jean, pant};
float
price;
public
cloth(Type t, Size s, String brand,
float
price, String bar){
type = t; size = s;
this
.brand = brand;
this
.price = price;
this
.barCode = bar;
}
}
public
class
clothstore {
Hashtable<String, cloth> catalog ;
Hashtable<String, Integer> storages;
clothstore(){
catalog =
new
Hashtable<String, cloth>();
storages =
new
Hashtable<String, Integer>();
}
void
addCloth(cloth c){
if
(!catalog.containsKey(c.barCode))
catalog.put(c.barCode, c);
int
count =
0
;
if
(storages.containsKey(c.barCode))
count = storages.get(c.barCode);
storages.put(c.barCode, count+
1
);
}
cloth sell(String barCode){
if
(!catalog.containsKey(barCode))
return
null
;
int
count = storages.get(barCode);
if
(count<=
0
)
return
null
;
cloth c = catalog.get(barCode);
count --;
storages.put(barCode, count);
return
c;
}
}