void main() {
Clothing jacket1 = Tops('black jacket', 'Gucci', 589.74, true);
Bottom jeans1 = Bottom('navy jeans', 'Zara', 299.99, false);
Tops tshirt1 = Tops('white T-shirt', 'Levis', 87.70, true);
Shoes sneakers1 = Shoes('Casual sneakers', 'Nike', 120.45, true);
jacket1.printClothing();
jeans1.printClothing();
tshirt1.printClothing();
sneakers1.printClothing();
tshirt1.washNecessity();
sneakers1.tooOld();
jeans1.washNecessity();
jeans1.selectPieces();
tshirt1.putThemInTheWash();
}
class Clothing {
String type;
String brand;
double price;
bool isWashNecessary;
Clothing(this.type, this.brand, this.price, this.isWashNecessary);
void printClothing() {
print('This/These $type is from $brand and it costed R\$ $price.');
}
void washNecessity() {
if (isWashNecessary) {
print('Put it in the wash. It will be grand.');
} else {
print('Put away in the wardrobe, it is clean.');
}
}
}
class Tops extends Clothing implements DoTheLaundry {
Tops(String type, String brand, double price, bool isWashNecessary)
: super(type, brand, price, isWashNecessary);
@override
void selectPieces() {
print('Remember that white pieces should not go with colors.');
}
@override
void putThemInTheWash() {
print('Use the correct detergent for the type of fabric');
}
@override
void startMachine() {
print('Select the best program according to your preference');
}
}
class Bottom extends Tops implements DoTheLaundry {
Bottom(String type, String brand, double price, bool washNecessary)
: super(type, brand, price, washNecessary);
@override
void selectPieces() {}
@override
void putThemInTheWash() {}
@override
void startMachine() {}
}
class Shoes extends Clothing {
bool isTooOld;
Shoes(String type, String brand, double price, this.isTooOld)
: super(type, brand, price, isTooOld);
void tooOld() {
if (isTooOld) {
print('Donate them to a charity.');
} else {
print('You may continue using them for a bit more');
}
}
}