-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clothes_manager.py
92 lines (77 loc) · 3.21 KB
/
clothes_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""Classes for creating user's garments and closets."""
from dataclasses import dataclass
@dataclass
class Garment:
"""Garment class to represent a clothing item (e.g. jeans)"""
def __init__(self, name: str, warmth: list) -> None:
"""initialize the garment with a name and warmth effect on the four parts of the body
Arguments:
name {str} - - name of garment
warmth{list} --[
head {int} - - warmth effect on head (0 to 10),
top {int} - - warmth effect on top (0 to 10),
bottom {int} - - warmth effect on bottom (0 to 10),
feet {int} - - warmth effect on feet (0 to 10)
]
"""
self.name = name
self.warmth = warmth
def __hash__(self):
return hash(tuple(self.warmth))
@dataclass
class Wardrobe:
"""Wardrobe class to represent a user's closet"""
def __init__(self) -> None:
self.contents = list()
def add_item(self, garment: Garment) -> None:
"""add an item to the closet
Arguments:
garment {Garment} -- the garment to be added
"""
self.contents.append(garment)
def change_warmth(self, name: str, warmth: list) -> None:
"""change an item's warmth
Arguments:
name {str} -- the name of the item whose warmth will change
warmth {list} -- the new warmth
"""
for item in self.contents:
if item.name == name:
garment_to_change = item
garment_to_change.warmth = warmth
def delete_by_name(self, name: str) -> None:
"""delete an item using its name
Arguments:
name {str} -- the name of the item to be deleted
"""
for index, item in enumerate(self.contents):
if item.name == name:
del self.contents[index]
def generic_clothes_generator(self) -> None:
"""Generate a set of garments for the closet
"""
self.contents.extend(
[
Garment("beanie", [2, 0, 0, 0]),
Garment("pom pom hat", [3, 0, 0, 0]),
Garment("trapper", [4, 0, 0, 0]),
Garment("short sleeve shirt", [0, 2, 0, 0]),
Garment("long sleeve shirt", [0, 3, 0, 0]),
Garment("sweatshirt", [0, 4, 0, 0]),
Garment("sweater", [0, 5, 0, 0]),
Garment("winter jacket", [0, 6, 0, 0]),
Garment("shorts", [0, 0, 1, 0]),
Garment("cargo shorts", [0, 0, 2, 0]),
Garment("sweatpants", [0, 0, 3, 0]),
Garment("slacks", [0, 0, 4, 0]),
Garment("jeans", [0, 0, 5, 0]),
Garment("khakis", [0, 0, 6, 0]),
Garment("cargo skiing pants", [0, 0, 7, 0]),
Garment("slip-on", [0, 0, 0, 2]),
Garment("sneakers", [0, 0, 0, 3]),
Garment("casual shoes", [0, 0, 0, 4]),
Garment("high-tops", [0, 0, 0, 5]),
Garment("uggs", [0, 0, 0, 6]),
Garment("boots", [0, 0, 0, 7]),
]
)