From 80976ba906eb78266a2955d4838a6ab372195694 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Fri, 27 Oct 2023 16:36:28 -0500 Subject: [PATCH] ex 3.1 a --- stock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stock.py b/stock.py index 134d200..1fb01ca 100644 --- a/stock.py +++ b/stock.py @@ -1,4 +1,3 @@ - class Stock: def __init__(self, name, shares, price): self.name = name @@ -7,3 +6,8 @@ class Stock: def cost(self): return self.shares * self.price + + def sell(self, num): + self.shares -= num + if self.shares < 0: + self.shares = 0