From 48a52b9a6780837e94ff5fd65a3dcbc920e48b69 Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:54:40 +0100 Subject: [PATCH 1/9] Update abstract_start.py There should be comments with tasks --- Start/Ch 2/abstract_start.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Start/Ch 2/abstract_start.py b/Start/Ch 2/abstract_start.py index dece2ad..9dfd151 100644 --- a/Start/Ch 2/abstract_start.py +++ b/Start/Ch 2/abstract_start.py @@ -1,15 +1,17 @@ # Python Object Oriented Programming by Joe Marini course example # Using Abstract Base Classes to enforce class constraints +#TODO: Import "ABC"(abstract base classes) and abstractmethod from abc +#TODO: Inherit from ABC indicates that this is an abstract base class class GraphicShape: def __init__(self): super().__init__() - + # declaring a method as abstract requires a subclass to implement it def calcArea(self): pass - +#TODO: Create specific versions of "calcArea" for different shapes class Circle(GraphicShape): def __init__(self, radius): self.radius = radius From c83292a99ac8bd688216d67ffee62f0fb01e189d Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:05:58 +0100 Subject: [PATCH 2/9] Update composition_start.py --- Start/Ch 2/composition_start.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Start/Ch 2/composition_start.py b/Start/Ch 2/composition_start.py index ccf9423..614c22c 100644 --- a/Start/Ch 2/composition_start.py +++ b/Start/Ch 2/composition_start.py @@ -1,7 +1,7 @@ # Python Object Oriented Programming by Joe Marini course example # Using composition to build complex objects - +#TODO: Arrange the composition of the Book class to operate on subclasses class Book: def __init__(self, title, price, authorfname, authorlname): self.title = title @@ -15,6 +15,13 @@ def __init__(self, title, price, authorfname, authorlname): def addchapter(self, name, pages): self.chapters.append((name, pages)) + #TODO: Method for counting the total number of pages from all chapters + +#TODO: Create classes "Chapter"(with attributes "name" and "pages") +# and "Author" with ("fname" and "lname") and a method __str__ returning author details + + +#TODO: Create an author object and add it to the book b1 = Book("War and Peace", 39.0, "Leo", "Tolstoy") From c2e3250dfab12e9ea0b94f6d68cc85acaf78987f Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:08:02 +0100 Subject: [PATCH 3/9] Update inheritance_start.py --- Start/Ch 2/inheritance_start.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Start/Ch 2/inheritance_start.py b/Start/Ch 2/inheritance_start.py index 7ac7685..31485b2 100644 --- a/Start/Ch 2/inheritance_start.py +++ b/Start/Ch 2/inheritance_start.py @@ -1,7 +1,12 @@ # Python Object Oriented Programming by Joe Marini course example # Understanding class inheritance +#TODO: Create a class "Publication" with attributes "title" and "price" +#TODO: Create a class "Perdiodicaly" that inherits from "Publication" +# and additionally has attributes "period" and "publisher" + +#TODO: Allow the "Book" class to inherit attributes from Publication class Book: def __init__(self, title, author, pages, price): self.title = title @@ -9,7 +14,7 @@ def __init__(self, title, author, pages, price): self.author = author self.pages = pages - +#TODO: The Magazine and Newspaper classes can inherit all atributes from "Perdiodicaly" class Magazine: def __init__(self, title, publisher, price, period): self.title = title From c17491e6876eaf91916faa5a6605c7aad36af3ca Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:10:24 +0100 Subject: [PATCH 4/9] Update interface_start.py --- Start/Ch 2/interface_start.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Start/Ch 2/interface_start.py b/Start/Ch 2/interface_start.py index adb6334..7027779 100644 --- a/Start/Ch 2/interface_start.py +++ b/Start/Ch 2/interface_start.py @@ -12,6 +12,7 @@ def __init__(self): def calcArea(self): pass +# TODO: Add abstract class "JSONify" with abstract method "toJSON" class Circle(GraphicShape): def __init__(self, radius): @@ -19,6 +20,8 @@ def __init__(self, radius): def calcArea(self): return 3.14 * (self.radius ** 2) + + # TODO: Override "toJSON" method to return a JSON representation of "calcArea" c = Circle(10) From 5000481087099636e84424dce81255400748eaf3 Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:13:49 +0100 Subject: [PATCH 5/9] Update multiple_start.py --- Start/Ch 2/multiple_start.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Start/Ch 2/multiple_start.py b/Start/Ch 2/multiple_start.py index 5e76252..dc5b9b6 100644 --- a/Start/Ch 2/multiple_start.py +++ b/Start/Ch 2/multiple_start.py @@ -1,7 +1,7 @@ # Python Object Oriented Programming by Joe Marini course example # Understanding multiple inheritance - +#TODO: For A and B class create an attribute "name" that will take different values class A: def __init__(self): super().__init__() @@ -17,6 +17,7 @@ def __init__(self): class C(A, B): def __init__(self): super().__init__() - + #TODO: Create the method "showprops" returning the attributes it owns c = C() +#TODO: You can use showprops() and also call "Class.__mro__" to find out all the parent classes From d83f7c202e9563867946d555f51303b959ad2018 Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:01:00 +0100 Subject: [PATCH 6/9] Update dataclass_start.py Just small hint ;) --- Start/Ch 4/dataclass_start.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Start/Ch 4/dataclass_start.py b/Start/Ch 4/dataclass_start.py index 77ee283..fa31476 100644 --- a/Start/Ch 4/dataclass_start.py +++ b/Start/Ch 4/dataclass_start.py @@ -1,6 +1,7 @@ # Python Object Oriented Programming by Joe Marini course example # Using data classes to represent data objects +#TODO: Import dataclasses from dataclass and apply decorator class Book: def __init__(self, title, author, pages, price): From 8821c5d122b818b2891ee78cdf947ca8c26edc1a Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:45:26 +0100 Subject: [PATCH 7/9] Update datadefault_start.py additional description --- Start/Ch 4/datadefault_start.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Start/Ch 4/datadefault_start.py b/Start/Ch 4/datadefault_start.py index 43998a1..c48cf60 100644 --- a/Start/Ch 4/datadefault_start.py +++ b/Start/Ch 4/datadefault_start.py @@ -1,8 +1,12 @@ # Python Object Oriented Programming by Joe Marini course example # implementing default values in data classes +# TODO: Import "field" function from dataclasses from dataclasses import dataclass +# TODO: Define a function that returns a random number between 20-40. +# Don't forget to import the necessary module + @dataclass class Book: @@ -11,3 +15,4 @@ class Book: author: str pages: int price: float + # TODO: Use the field function to get default price as random number From 662eeeeffef37b19cf142744885a2035085f40e1 Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:46:35 +0100 Subject: [PATCH 8/9] Update immutable_start.py small comment --- Start/Ch 4/immutable_start.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Start/Ch 4/immutable_start.py b/Start/Ch 4/immutable_start.py index d214eab..41c8710 100644 --- a/Start/Ch 4/immutable_start.py +++ b/Start/Ch 4/immutable_start.py @@ -10,7 +10,7 @@ class ImmutableClass: value2: int = 0 -obj = ImmutableClass() +obj = ImmutableClass() # You can set the values of frozen class only with initialization print(obj.value1) # TODO: attempting to change the value of an immutable class throws an exception From f476d9d911b9456a3197661abaa5f5a4182b314d Mon Sep 17 00:00:00 2001 From: SHypoleac <153895174+SHypoleac@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:51:07 +0100 Subject: [PATCH 9/9] Update challenge.py incorrect values --- Finished/Ch 4/challenge.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Finished/Ch 4/challenge.py b/Finished/Ch 4/challenge.py index 0cb2b0b..e48751a 100644 --- a/Finished/Ch 4/challenge.py +++ b/Finished/Ch 4/challenge.py @@ -33,10 +33,10 @@ def __lt__(self, other): # ~~~~~~~~~ TEST CODE ~~~~~~~~~ stocks = [ - Stock("MSFT", 342.0, "Microsoft Corp"), - Stock("GOOG", 135.0, "Google Inc"), - Stock("META", 275.0, "Meta Platforms Inc"), - Stock("AMZN", 120.0, "Amazon Inc") + Stock(342.0, "MSFT", "Microsoft Corp"), + Stock(135.0, "GOOG", "Google Inc"), + Stock(275.0, "META", "Meta Platforms Inc"), + Stock(120.0, "AMZN", "Amazon Inc") ] bonds = [