Skip to content

Commit b2d760c

Browse files
Karen AlabiKaren Alabi
authored andcommitted
feat: implements createOutfit method to pick clothes based on season
1 parent eb78119 commit b2d760c

File tree

1 file changed

+16
-2
lines changed
  • lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/wardrobecollection

1 file changed

+16
-2
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/wardrobecollection/PersonalCloset.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,22 @@ public void removeItem(ClothingItem item) throws ItemNotFoundException {
7373

7474

7575
// method creates outfit by selecting items based on the season
76-
public List<Clothing Item> createOutfit(Season season) {
77-
return new ArrayList<>();
76+
public List<ClothingItem> createOutfit(Season season) {
77+
// creating empty list that stores clothing items
78+
List<ClothingItem> outfit = new ArrayList<>();
79+
80+
// iterating through all items in the closet and grabbing item at index
81+
for (int i = 0; i < items.size(); i++) {
82+
ClothingItem item = items.get(i);
83+
84+
//check if clothign item matches particular season or is good for all seasons
85+
if (item.getSeason() == season || item.getSeason() == Season.ALL_SEASON) {
86+
//add item to list
87+
outfit.add(item);
88+
}
89+
}
90+
// returns final list of clothing items in an outfit
91+
return outfits;
7892
}
7993

8094
// method organizes closet by type of item and color

0 commit comments

Comments
 (0)