示例#1
0
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)
# 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'
print(shirt_one.size)
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)
示例#4
0
#        - 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
#    - store the object in a variable called shirt_two
#
###
shirt_two = Shirt('orange', 'L', 'short-sleeve', 10)

### TODO:
#
#    - calculate the total cost of shirt_one and shirt_two
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)
示例#6
0
from shirt import Shirt

shirt_one = Shirt('red', 'M', 'long_sleeve', 45)
shirt_two = Shirt('orange', 'S' ,'short_sleeved', 30)

print(shirt_one.price)
print(shirt_one.color)

shirt_two.change_price(45)
print(shirt_two.price)


shirt_one.color = 'yellow'
shirt_one.size = 'L'
shirt_one.price = 43
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)
示例#8
0
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))
示例#9
0
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)