diff --git a/5-Card_Stud_Poker_Game (Final).py b/5-Card_Stud_Poker_Game (Final).py index fc2bbfc..f70bca0 100644 --- a/5-Card_Stud_Poker_Game (Final).py +++ b/5-Card_Stud_Poker_Game (Final).py @@ -225,7 +225,7 @@ def reset_round(players): class Deck: def __init__(self): self.cards: List[Card] = [Card(rank, suit) for suit in SUITS for rank in RANKS] - random.seed(time.time()) + random.seed(time.time()) # Seed random number generator with current time random.shuffle(self.cards) def deal_card(self) -> Card: diff --git a/MyProductClass.py b/MyProductClass.py new file mode 100644 index 0000000..371cb69 --- /dev/null +++ b/MyProductClass.py @@ -0,0 +1,36 @@ +class Product: + pay_rate = 0.8 # Class variable for a standard discount of 20% + def __init__(self, name, price, quantity): + assert price >= 0, f"Product price {price} is not greater than or equal to zero!" + assert quantity >= 0, f"Product quantity {quantity} is not greater than or equal to zero!" + self.name = name + self.price = price + self.quantity = quantity + + def calculate_total_price(self): + return self.price * self.quantity + + def apply_discount(self): + return self.calculate_total_price() * (self.pay_rate) + +# Example usage: +if __name__ == "__main__": + + item1 = Product("Laptop", 1000, 2) # Item with standard discount + item2 = Product("Smartphone", 100, 3) # Item with special discount + + print(f'Price of {item1.name}: ${item1.price:.2f}') + print(f'Price of {item1.name} after 20% discount: ${item1.price * Product.pay_rate:.2f}') + print(f"Total price for {item1.name}(s) after 20% discount: ${item1.apply_discount():.2f}") # Applying standard discount + print() + item2.pay_rate = 0.7 # Instance variable for a special discount of 30% + print(f'Price of {item2.name}: ${item2.price:.2f}') + print(f'Price of {item2.name}(s) after 30% discount: ${item2.price * item2.pay_rate:.2f}') + print(f"Total price for {item2.name}(s) after 30% discount: ${item2.apply_discount():.2f}") # Applying item-specific discount + + + + + + + \ No newline at end of file