2. Objects

  • Feel free to use your laptop

  • You are strongly encourage to work with others

    • When you get stuck, ask those sitting around you for help

    • Get used to working together in the labs

    • Peer teaching and peer learning has been empirically shown to be very effective

2.1. Creating Objects

The goal is to make a program that will keep track of a suite of courses. To do this, two classes will be written — one for keeping track of the information about a single course, and another for keeping track of multiple courses. In this lab, the Course class will be created.

2.1.1. Course Class

A Course is a simple object to keeps track of data. Refer to the objects review topic for guidance on creating this class.

  1. Create a class called Course that has three private fields: programCode, courseCode, and courseTitle

    • For example, a data structures course could have the following values for the fields

      • programCode"CS"

      • courseCode"102"

      • courseTitle"Programming and Data Structures"

  2. Write a single constructor to take and assign values to the fields

  3. Write accessor methods for the three fields

    • For example, getCourseCode

  4. Write a toString method that returns a string representation of the object

    • The string should be of the form "Course(programCode, courseCode, courseTitle)"

  5. Write an equals method that checks if two Course objects are equivalent

    • Two Course objects are considered equal if all their fields match

    • Remember, do not check string equality with ==

  6. Write a hashCode method

  7. Test the Course class by making instances of them and calling the methods to see if they work as expected

    • Create a few instances of the Course class in main

    • Call their methods and check if their behaviour is as expected

    • Be sure to check all methods

2.2. Kattis Problems

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

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

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

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

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

  6. https://open.kattis.com/problems/twostones

  7. https://open.kattis.com/problems/spavanac

  8. https://open.kattis.com/problems/cetvrta

  9. https://open.kattis.com/problems/bus

  10. https://open.kattis.com/problems/timeloop

  11. https://open.kattis.com/problems/oddities

  12. https://open.kattis.com/problems/fizzbuzz

  13. https://open.kattis.com/problems/sibice

  14. https://open.kattis.com/problems/datum

  15. https://open.kattis.com/problems/dicecup

  16. https://open.kattis.com/problems/autori

  17. https://open.kattis.com/problems/apaxiaaans

  18. https://open.kattis.com/problems/hissingmicrophone

  19. https://open.kattis.com/problems/trik

  20. https://open.kattis.com/problems/pot

  21. https://open.kattis.com/problems/filip

  22. https://open.kattis.com/problems/reversebinary

  23. https://open.kattis.com/problems/sevenwonders

  24. https://open.kattis.com/problems/zamka

  25. https://open.kattis.com/problems/bijele

  26. https://open.kattis.com/problems/cold

  27. https://open.kattis.com/problems/nastyhacks

  28. https://open.kattis.com/problems/grassseed

  29. https://open.kattis.com/problems/pet

  30. https://open.kattis.com/problems/batterup

  31. https://open.kattis.com/problems/aboveaverage

  32. https://open.kattis.com/problems/icpcawards

  33. https://open.kattis.com/problems/quickbrownfox

  34. https://open.kattis.com/problems/nodup

  35. https://open.kattis.com/problems/conundrum

  36. https://open.kattis.com/problems/bela

  37. https://open.kattis.com/problems/kornislav