Skip to content

Commit 2e622f1

Browse files
committed
update challenge descriptions
1 parent 1117272 commit 2e622f1

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

Start/Ch 1/challenge.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Python Object Oriented Programming by Joe Marini course example
22
# Programming challenge: define a class to represent a stock symbol
33

4+
# Challenge: create a class to represent stock information.
5+
# Your class should have properties for:
6+
# Ticker (string)
7+
# Price (float)
8+
# Company (string)
9+
# And a method get_description() which returns a string in the form
10+
# of "Ticker: Company -- $Price"
411

512
class Stock:
613
pass

Start/Ch 2/challenge.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# Python Object Oriented Programming by Joe Marini course example
22
# Programming challenge: use inheritance and abstract classes
33

4-
from abc import ABC, abstractmethod
4+
# Challenge: create a class structure to represent stocks and bonds
5+
# Requirements:
6+
# -- Both stocks and bonds have a price
7+
# -- Stocks have a company name and ticker
8+
# -- Bonds have a description, duration, and yield
9+
# -- You should not be able to instantiate the base class
10+
# -- Subclasses are required to override get_description()
11+
# -- get_description returns formats for stocks and bonds
12+
# For stocks: "Ticker: Company -- $Price"
13+
# For bonds: "description: duration'yr' : $price : yieldamt%"
514

615
class Asset():
716
pass

Start/Ch 3/challenge.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Python Object Oriented Programming by Joe Marini course example
22
# Programming challenge: add methods for comparison and equality
33

4+
# Challenge: use a magic method to make stocks and bonds sortable
5+
# Stocks should sort from low to high on price
6+
# Bonds should sort from low to high on yield
7+
48
from abc import ABC, abstractmethod
59

610

Start/Ch 4/challenge.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# Python Object Oriented Programming by Joe Marini course example
22
# Programming challenge: implement a dataclass
33

4-
from dataclasses import dataclass
5-
from abc import ABC, abstractmethod
4+
# Challenge: convert your classes to dataclasses
5+
# The subclasses are required to override the magic method
6+
# that makes them sortable
67

78
class Asset():
89
pass
910

1011

1112
class Stock(Asset):
12-
pass
13+
pass
1314

1415

1516
class Bond(Asset):
16-
pass
17+
pass
1718

1819
# ~~~~~~~~~ TEST CODE ~~~~~~~~~
1920
stocks = [

0 commit comments

Comments
 (0)