Eleventh lab: A few simple classes

11 Mar 2022 - 14:41 | Version 1 |

Learning Objective(s)

  1. Learn to develop some classes
  2. Create some classes that will help with the project

Overview of the program

You are to create three classes that will help with the final project.

Details

  • Date class: This class should be able to represent a valid date (year, month, day).
    • The constructor should "reject" creating an invalid date. (It should receive year, month, and day in that order)
    • It needs all standard accessors.
    • Because dates don't change, it does not need any mutators.
    • It needs the three standard helper methods (toString, equals, and compareTo). It should implement Comparable
    • It should have a class method that when given a year and a month (in that order), it returns the number of days.
  • Task class: This class should represent a given task (number of hours and a description)
    • The constructor should accept the description, followed by the number of hours (which can contain a fraction of an hour).
    • It should have all the standard accessors, mutators, and helper methods (toString, equals, compareTo). Two tasks are equal if they have the same description and hours. Tasks are ordered by the number of hours. It should implement Comparable
  • Day class: This class has a given day and a list of tasks.
    • The maximum number of tasks in a day is 50.
    • It should have two constructors (both sent a given date → in two different formats)
    • Besides the standard accessors it should also have a method that returns the total number of hours for that day.
    • The date of a task cannot change.
    • Once added, tasks cannot be removed or changed.
    • Tasks can be added (by sending a task or a description and number of hours).
    • The toString method should return a nicely formatted string with all tasks and the total number of hours for that date
    • Two days are the same if they are for the same date.
    • Days are order by the compareTo method based upon the total hours. It should implement Comparable.
  • You may use a driver to test your methods or describe how you used JGrasp's workbench in your testing report. Be sure to test each class completely.
  • All normal exceptions should be handled (not thrown)

Submission

  1. Create an empty zip folder.
  2. Place your classes (.java files) in it
  3. Place your software development report in it.
  4. Submit the zip folder on canvas

Optional improvements

Nothing here. If you have time, work on the next lab.
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This website is using cookies. More info. That's Fine