1 of 6

ME 4990: Intro to CS�Object-Oriented Programming & Machine Learning 101

Class Practice

2 of 6

Outline

  • Triangle Practice
  • Bank: a design thought

3 of 6

Triangle

  • Write a triangle class
  • Attributes?
  • Methods
    • Get angle using law of cosine
    • Calculate perimeter
    • Calculate area
    • __str__ method to print all angles, perimeter, and calculated area

4 of 6

Triangle

  • Law of cosine function is provided to you as a function
  • Validation of a triangle method is provided to you
  • Finish perimeter, angle finding, and area

5 of 6

Bank

  • Make a class BankAccount
    • Maintain the balance
    • Allows Account owners to operate (deposit, withdraw)

6 of 6

Bank Account

  • It is an open discussion

  • Design your class with new methods and attributes, to save all transaction records
  • Allow account holder to print out the list of transactions
    • Use datetime.now() to get the current date and time
    • The print should be like a bank statement, e.g.
    • 2021-3-3 13:24:10, deposit, 500
    • 2022-4-4 13:24:10, withdraw, 300