10. Objects

  • Feel free to use your laptop if you have it

  • Ensure I have recorded your completion — failure to do so will result in a grade of 0

  • I strongly encourage you to work with others in the lab

    • When you get stuck, do me a favour and ask those sitting around you for help

    • I want people to get used to working together in the labs

    • Peer teaching and peer learning is super effective

Note

To obtain full marks for the lab, you must:

  1. Have completed the pre-lab exercises

  2. Have been working on the lab content

  3. Demonstrate competency in the topics

10.1. Pre Lab Exercises

  • Have a working implementation of the Circle class from lecture

    • You can obtain the source code from here

    • Yes, this week’s pre-lab exercise is intended to be simple

    • It will provide a nice template for all the classes you will make in this lab

10.2. Before Kattis

  1. Create a Square class

    • Single attribute side_length

    • The constructor will take a parameter for specifying the size

    • Method for calculating area()

    • Method for calculating the perimeter()

    • Make instances of the class and write assert tests to verify correctness

  2. Create a Rectangle class

    • Attribute for length

    • Another attribute for width

    • The constructor will take two parameters for specifying the size

    • Method for calculating area()

    • Method for calculating the perimeter()

    • Make instances of the class and write assert tests to verify correctness

  3. Create a RectangularPrism class

    • Attributes for length, width, and height

    • The constructor will take three parameters for specifying the size

    • A method for calculating surface_area()

    • A method for calculating volume()

    • Make instances of the class and write assert tests to verify correctness

  4. Create a Person class

    • Attribute for first_name

    • Attribute for last_name

    • Attribute for email_address

    • The constructor will take three parameters for specifying the values of the attributes

    • A method returning a string of their full_name() — e.g. `Bob Smith

    • Make instances of the class and write assert tests to verify correctness

10.3. Kattis Problems

  • You should be using a scrap piece of paper to work out the ideas for the following problems

    • The problems you are to solve are getting too complex to try to solve by just coding

    • Trying to solve problems by just typing away will not yield success

  1. https://open.kattis.com/problems/everywhere

  2. https://open.kattis.com/problems/babelfish

  3. https://open.kattis.com/problems/oddmanout

  4. https://open.kattis.com/problems/securedoors

  5. https://open.kattis.com/problems/modulo

Warning

Ensure that your your completion has been recorded. Failure to do so may result in a grade of 0.