def main(): shirt_one = Shirt('red', 'S', 'short-sleeve', 15) shirt_two = Shirt('yellow', 'M', 'long-sleeve', 20) print(shirt_one.get_price()) # change price of shirt one to 30 shirt_one.set_price(30) print(shirt_one.get_price()) # print shirt two color print(shirt_two.get_color())
def get_frame(self): success, image = self.video.read() if success: # We are using Motion JPEG, but OpenCV defaults to capture raw images, # so we must encode it into JPEG in order to correctly display the # video stream. (h, w, d) = image.shape # w:h == 9:16 width = math.floor((9 * h / 16) / 2) stx = math.floor(w / 2) - width endx = math.floor(w / 2) + width img = image[0:h, stx:endx] if not self.initialized: # Add silouhette gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) resized = cv2.resize(self.silouhette, (endx - stx, h)) head_x = math.floor((endx - stx) / 2) head_y = math.floor(h * 140 / 720) faces = face_cascade.detectMultiScale(gray, 1.3, 5) if len(faces) > 0: (x, y, wf, hf) = faces[0] x_c = math.floor(x + wf / 2) y_c = math.floor(y + hf / 2) # print(abs(head_x-x)+abs(head_y-y)) if abs(head_x - x_c) + abs(head_y - y_c) < 50: if wf < (endx - stx) / 2: self.initTimer += 1 cv2.rectangle(img, (x, y), (x + wf, y + hf), (0, 255, 0), 2) else: cv2.rectangle(img, (x, y), (x + wf, y + hf), (0, 255, 255), 2) else: cv2.rectangle(img, (x, y), (x + wf, y + hf), (0, 0, 255), 2) if self.initTimer >= 100: self.shirt = Shirt(img) self.initialized = True img = cv2.add(img, resized) else: # Can colorize if needed if self.colorize and self.shirt is not None: img = self.shirt.change_color(img, self.color) ret, jpeg = cv2.imencode('.jpg', img) return jpeg.tobytes() else: return None
from shirt import Shirt print("Hello") sh_1 = Shirt('red','S','short sleeve', 15) sh_2 = Shirt('orange','L','long sleeve', 30) print(sh_1.price) print(sh_2.price) print(sh_3.price)
from shirt import Shirt shirt_one = Shirt('orange', 'M', 'short sleeve', 25) shirt_two = Shirt('red', 'S', 'short sleeve', 15) shirt_three = Shirt('purple', 'XL', 'short sleeve', 10) print(shirt_one.price) print(shirt_two.color) shirt_three.change_price(45) print(shirt_three.price) shirt_three.convert_euros(45) print(shirt_three.price)
from shirt import Shirt new_shirt = Shirt('Red', 'M', 'short sleeve', 50) print(new_shirt.color) print(new_shirt.size) print(new_shirt.style) # change price method new_shirt.change_price(32) print(new_shirt.price) # discount method print(new_shirt.discount(0.2)) tshirt_collection = [] shirt_one = Shirt('red', 'S', 'short-sleeve', 15) short_two = Shirt('blue', 'M', 'long-sleeve', 35) short_three = Shirt('yellow', 'L', 'short-sleeve', 20) tshirt_collection.append(shirt_one) tshirt_collection.append(short_two) tshirt_collection.append(short_three) for i in range(len(tshirt_collection)): print(tshirt_collection[i].color)
from shirt import Shirt shirt_one = Shirt('red', 'S', 'Full-sleeve', 15) shirt_two = Shirt('Blue', 'M', 'Half sleeve', 10) #print(shirt_one.price) #print(shirt_two.price) #shirt_two.change_price(20) #print(shirt_two.price) #shirt_one.price = 18 #shirt_one.style = 'tank' shirt_one = Shirt('yellow', 'M', 'long-sleeve', 15) print(shirt_one.get_price()) shirt_one.set_price(10)
### TODO: # - import the Shirt class from the shirt.py file ### from shirt import Shirt ### TODO: # - insantiate a shirt object with the following characteristics: # - color red, size S, style long-sleeve, and price 25 # - store the object in a variable called shirt_one # # ### shirt_one = Shirt("red", "S", "long-sleeve", 25) ### TODO: # - print the price of the shirt using the price attribute # - change the price of the shirt to be 10 # - print the price of the shirt using the price attribute # - print the price of the shirt with a 12% discount # ### print(shirt_one.price) shirt_one.change_price(10) print(shirt_one.price) print(shirt_one.discount(0.12)) ### TODO: # # - instantiate another object with the following characteristics: # . - color orange, size large, style short sleeve, and price 10
from shirt import Shirt shirt_one = Shirt('red', 'L', 'long-sleeve', 25) print(shirt_one.price) shirt_one.price = 10 print(shirt_one.price) shirt_one.price = 20 print(shirt_one.price) shirt_one.color = 'yellow' print(shirt_one.color) shirt_one.size = 'M' print(shirt_one.size) shirt_one.style = 'short_sleeve' print(shirt_one.style)
from shirt import Shirt from shirt import Jean shirt_one = Shirt('orange', 'S', 'long sleeve', 45) shirt_two = Shirt('red', 'XL', 'short sleeve', 30) print(shirt_one.color) print(shirt_two.price) shirt_two.change_price(23) print(shirt_two.price) print(shirt_one.discount(.1)) shirt_one.color = 'purple' shirt_one.size = 'L' shirt_one.price = 38 jean_one = Jean('red', 'L', 70) print(jean_one.color) print(jean_one.size) print(jean_one.price)
from shirt import Shirt shirt_1 = Shirt('black', 'M', 'Full-Sleeves', 100) print(shirt_1.price)
from arduinoController import ArduinoController from belt import Belt from mechanicalClaw import MechanicalClaw from trapdoors import Trapdoors board = Arduino('/dev/ttyACM0') belt = Belt(board) claw = MechanicalClaw(board) trapdoors = Trapdoors(board) controller = ArduinoController(board, claw, belt, trapdoors) # Erase the example and insert your shirt list shirtDisorderedList = [ Shirt("big", "blue"), # a BIG and BLUE shirt Shirt("small", "blue"), # a SMALL and BLUE shirt Shirt("big", "red"), # a BIG and RED shirt Shirt("small", "red"), # Notice that the constructor Shirt("big", "yellow"), # is built by two arguments Shirt("small", "yellow") # first the color, then the size ] palletizer = Palletizer(shirtDisorderedList) shirtsDestiny = [] currentSize = "" while palletizer.dynamicShirtList: # While there is any shirt in the provided list that wasn't placed and processed palletizer.separateByModel() shirtsDestinys = palletizer.getTrapdoorsOrder()
from shirt import Shirt if __name__ == '__main__': shirt_1 = Shirt('red', 'M', 'long_sleeved', 55) shirt_2 = Shirt('orange', 'S', 'short_sleeved', 30) print(shirt_1.get_price()) print(shirt_2.get_price()) print(shirt_1.discount(0.81)) shirt_1.change_price(60) print(shirt_1.discount(0.81))
from shirt import Shirt from pants import Pants new_shirt = Shirt("blue","14","Polo",45) new_pants = Pants ("blue","14","Polo",45) print(new_shirt._color) print(new_pants._price)
### TODO: # - import the Shirt class from the shirt.py file ### from shirt import Shirt ### TODO: # - insantiate a shirt object with the following characteristics: # - color red, size S, style long-sleeve, and price 25 # - store the object in a variable called shirt_one # # ### shirt_one = Shirt('red', 'S', 'long-sleeve', 25) ### TODO: # - print the price of the shirt using the price attribute # - change the price of the shirt to be 10 # - print the price of the shirt using the price attribute # - print the price of the shirt with a 12% discount # ### print(shirt_one.price) shirt_one.change_price(10) print(shirt_one.price) print(shirt_one.discount(.12)) ### TODO: # # - instantiate another object with the following characteristics: # . - color orange, size large, style short sleeve, and price 10
from shirt import Shirt shirt_one = Shirt('red', 'M', 'long_sleeved', 45) shirt_two = Shirt('orange', 'S', 'short_sleeved', 30) print(shirt_two.price) print(shirt_one.color)
from shirt import Shirt new_shirt = Shirt('red', 's', 'short sleeve', 45) orange_shirt = Shirt('orange', 'L', 'short sleeve', 15) print(new_shirt.__doc__) # print print(new_shirt.color) print(new_shirt.size) print(new_shirt.style) print(new_shirt.price) new_price = new_shirt.change_price(10) print(new_shirt.price) new_discount = new_shirt.discount(0.3) print(new_discount)
from shirt import Shirt # import Shirt class from python file shirt_one = Shirt('red', 'M', 'long sleeve', 35) shirt_two = Shirt('red', 'S', 'short sleeve', 30) print(shirt_one.price) print(shirt_two.price) shirt_two.price_change(45) print(shirt_one.price) print(shirt_two.price) # alternatively, we can chage the attribute, like price using accessing attributes # this approach has its own drawbacks # so, it's recommended to change the attribute value with method # since it brings us more flexibility, when, for example, our measure units change # we can specify the change once inide class method and use this afterwards shirt_one.color = 'yellow' shirt_two.size = 'L' print(shirt_one.color) print(shirt_two.size)
#!/usr/bin/env python # coding: utf-8 from shirt import Shirt shirt_one=Shirt('Red','M','long-sleeved',45) shirt_two=Shirt('orange','S','short-sleeved',30) print(shirt_one.color) print(shirt_one.price) shirt_two.change_price(45) # price change using method print(shirt_two.price) # How to access and change attribute values in python class # Shirt class has method to change shirt price # Values can be changed either by assigning value or by using method shirt_one.color='Green' print(shirt_one.color) shirt_one.size='L'
from shirt import Shirt shirt1 = Shirt('red', 'M', 'long_sleeved', 43) shirt2 = Shirt('orange', 'S', 'short_sleeved', 30) print(shirt1.price) print(shirt2.color) print(shirt2.style) shirt2.change_price(45) print(shirt2.price)