In this question we will be designing an application to make outfit suggestions.
ID: 666596 • Letter: I
Question
In this question we will be designing an application to make outfit suggestions. Your first step
is to define the classes to represent the clothing items you will need along with constructors,
attributes, and getters/setters as appropriate . You will need base classes for at
least the following:
• Shirts (t-shirts, sweaters, button-up shirts, turtlenecks, etc.)
• Pants (jeans, khakis, slacks, capris, shorts, etc.)
• Outerwear (spring coat, winter jacket, etc.)
• Shoes (dress shoes, running shoes, steel-toed boots, etc.)
• Accessories (rings, earrings, watches, ties, etc.)
For each of these base classes you will be expected to implement a number of sub classes that
inherit from these base classes. For example, you may make a Shirt class that has Tshirt,
Sweater, ButtonUpShirt, etc as sub-classes. Make sure you represent enough clothing items
that your outfit planner can actually suggest a reasonable number of different combinations
of outfits. If you get to the end of the program and find you need more, just come back and
add new items.
In each of your clothing/accessory classes, write methods that have no parameters and return
boolean values. These methods will ask various questions about the clothing/ accessory item,
like whether it is plain or colourful, fancy or casual, good with earrings, good with dress
shoes, etc. (add your own characteristics, too!) . These will be used to determine
what combinations of clothing do not make a good outfit. It is important that the base
class(es) for each category of clothing/accessory have these methods as well, perhaps as
abstract methods, so that you can store lists using the base class types and call the methods
without casting.
Next, you will create a class (or classes) that will take care of generating good outfit suggestions. Inside, store lists for the following clothing/accessory types :
• Shirts
• Pants
• Outerwear
• Shoes
• Accessories
The lists will store a base class type, but you will be able to add that type of object and any
subclasses of the base class to the list. As long as the base class has the necessary methods
defined (i.e., the characteristic methods from the previous step), polymorphism will allow
you to use the objects correctly without casting back to their original types. You are expected to have a relatively large number of objects stored in this outfit generating class.
Ensure you have a good number of objects from each category with a total of at least 30
objects stored across the five lists.
Add a method (or methods) that will take one item from each of the five above types stored
in the lists and decide whether it makes a good outfit. Use the characteristic
methods you defined earlier to check whether the given combination is good. Here are some
ideas for rules you could apply (as usual, add your own as well):
• The shirt, pants, and shoes should not all be plain
• A shirt that is not good with dress shoes shouldnt be worn with dress shoes
• A winter jacket shouldnt be worn with shorts
• A tie shouldnt be worn with jeans
• Blue and green together should be avoided
Add a method (or methods) that generate outfit possibilities by randomly choosing an item
from each of the five categories, testing the combination with the rules you created above,
and repeating until a good combination is found .
Add a testing class and test all of your methods, including printing out several of the combinations your outfit generator comes up with .
Explanation / Answer
Acessory.java
public interface Accessory {
// Returns an integer unique to a specific position on you the body.
public int getPosition();
public int getCasualness();
// If this accessory is compatible with sleeved shirts.
public boolean getFitsSleeves();
public boolean goodWithShorts();
public int getSeason();
}
Capris.java
public class Capris implements Pants {
public boolean isAnkleLength() {
return false;
}
public int getCasualness() {
return 7;
}
public boolean hasPockets() {
return false;
}
public boolean getRipped() {
return false;
}
public boolean getSkinTight() {
return false;
}
public int getSeason() {
return -1;
}
public String toString() {
return "Capris";
}
}
DressShirt.java
public class DressShirt implements Shirt {
public boolean hasButtons() {
return true;
}
public boolean hasCollar() {
return true;
}
public int getCasualness() {
return 1;
}
public int getSeason() {
// TShirts are pretty neutral.
return -1;
}
public String toString() {
return "Dress Shirt";
}
}
Hat.java
public class Hat implements Accessory {
// Returns an integer unique to a specific position on you the body.
public int getPosition() {
return 2;
}
public int getCasualness() {
// Super formal
return 4;
}
// If this accessory is compatible with sleeved shirts.
public boolean getFitsSleeves() {
return true;
}
public boolean goodWithShorts() {
return false;
}
public int getSeason() {
return -1;
}
public String toString() {
return "Hat";
}
}
jeans.java
public class Jeans implements Pants {
public boolean isAnkleLength() {
return true;
}
public int getCasualness() {
return 7;
}
public boolean hasPockets() {
return true;
}
public boolean getRipped() {
return false;
}
public boolean getSkinTight() {
return false;
}
public int getSeason() {
return -1;
}
public String toString() {
return "Jeans";
}
}
Khakis.java
public class Khakis implements Pants {
public boolean isAnkleLength() {
return true;
}
public int getCasualness() {
return 4;
}
public boolean hasPockets() {
return true;
}
public boolean getRipped() {
return false;
}
public boolean getSkinTight() {
return false;
}
public int getSeason() {
return -1;
}
public String toString() {
return "Khakis";
}
}
Necklace.java
public class Necklace implements Accessory {
// Returns an integer unique to a specific position on you the body.
public int getPosition() {
return 2;
}
public int getCasualness() {
// Super formal
return 4;
}
// If this accessory is compatible with sleeved shirts.
public boolean getFitsSleeves() {
return true;
}
public boolean goodWithShorts() {
return false;
}
public int getSeason() {
return -1;
}
public String toString() {
return "Necklace";
}
}
Outerwear.java
public interface Outerwear {
public boolean isSporty();
public int getSeason();
//public boolean is
}
Outfit.java
public class Outfit {
//private Shoes shoes;
private Pants pants;
private Shirt shirt;
private Accessory accessory;
private Outerwear outerwear;
public String toString() {
// Comma separated list of the stuff in our outfit.
//System.out.println(shoes.toString() + ", " + pants.toString() + ", " + shirt.toString() + ", " + accessory.toString());
System.out.println(pants.toString() + ", " + shirt.toString() + ", " + accessory.toString());
//return toString;}
// Uses a set of rules to calculate a score (out of 100%)
public int calcScore() {
// All outfits are super fashionable atm
return 100;
}
}
OutfitSuggester.java
import java.util.List;
import java.util.ArrayList;
public class OutfitSuggester {
List<Shirt> shirts = new ArrayList<>();
List<Pants> pants = new ArrayList<>();
List<Outerwear> outerwear = new ArrayList<>();
List<Accessory> accessories = new ArrayList<>();
public OutfitSuggester() {
addClothes();
}
public void addClothes() {
shirts.add(new DressShirt());
shirts.add(new TShirt());
shirts.add(new PoloShirt());
shirts.add(new TankTop());
accessories.add(new SonicScrewdriver());
accessories.add(new Watch());
accessories.add(new Necklace());
accessories.add(new Hat());
pants.add(new Jeans());
pants.add(new Khakis());
pants.add(new Capris());
pants.add(new Shorts());
// shoes.add(new Loafers());
// shoes.add(new Heels());
// shoes.add(new Sandals());
// shoes.add(new Converse());
}
}
pants.java
public interface Pants {
public boolean isAnkleLength();
public int getCasualness();
public boolean hasPockets();
public boolean getRipped();
public boolean getSkinTight();
public int getSeason();
}
PoloShirt.java
public class PoloShirt implements Shirt {
public boolean hasButtons() {
return true;
}
public boolean hasCollar() {
return true;
}
public int getCasualness() {
return 5;
}
public int getSeason() {
// TShirts are pretty neutral.
return -1;
}
public String toString() {
return "Polo Shirt";
}
}
RipppedSkinnyJeans.java
// AKA Hipster Jeans
public class RippedSkinnyJeans extends SkinnyJeans {
public boolean getRipped() {
return true;
}
public String toString() {
return "Ripped Skinny Jeans";
}
}
Shirt.java
public interface Shirt {
public boolean hasButtons();
public boolean hasCollar();
public int getCasualness();
public int getSeason();
}
Shoes.java
public interface Shoes {
public boolean ;
}
Shorts.java
public class Shorts implements Pants {
public boolean isAnkleLength() {
return false;
}
public int getCasualness() {
return 10;
}
public boolean hasPockets() {
return true;
}
public boolean getRipped() {
return false;
}
public boolean getSkinTight() {
return false;
}
public int getSeason() {
// Summer
return 2;
}
public String toString() {
return "Shorts";
}
}
SkinnyJeans.java
public class SkinnyJeans extends Jeans {
public boolean getSkinTight() {
return true;
}
public String toString() {
return "Skinny Jeans";
}
}
SonicScrewdriver.java
public class SonicScrewdriver implements Accessory {
// Returns an integer unique to a specific position on you the body.
public int getPosition() {
return 1;
}
public int getCasualness() {
// Super formal
return 0;
}
// If this accessory is compatible with sleeved shirts.
public boolean getFitsSleeves() {
return true;
}
public boolean goodWithShorts() {
return true;
}
public int getSeason() {
return -1;
}
public String toString() {
return "Sonic Screwdriver";
}
}
TankTop.java
public class TankTop implements Shirt {
public boolean hasButtons() {
return false;
}
public boolean hasCollar() {
return false;
}
public int getCasualness() {
return 10;
}
public int getSeason() {
// TShirts are pretty neutral.
return -1;
}
public String toString() {
return "Tank Top";
}
}
Tshirt.java
public class TShirt implements Shirt {
public boolean hasButtons() {
return false;
}
public boolean hasCollar() {
return false;
}
public int getCasualness() {
return 10;
}
public int getSeason() {
// TShirts are pretty neutral.
return -1;
}
public String toString() {
return "T-Shirt";
}
}
Watch.java
public class Watch implements Accessory {
// Returns an integer unique to a specific position on you the body.
public int getPosition() {
return 1;
}
public int getCasualness() {
return 3;
}
// If this accessory is compatible with sleeved shirts.
public boolean getFitsSleeves() {
return true;
}
public boolean goodWithShorts() {
return true;
}
public int getSeason() {
return -1;
}
public String toString() {
return "Watch";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.