On this page:
Problem 1: Tasks and abstraction
Problem 2:   Problem Solving Practice
8.5

Lab 4: Working with Abstract Classes, Problem Solving

Partners: You will get a partner in lab today. If you and another student *in your lab section* agree that you want to work together, you may make a request in handins to be partners. Both of you must make this request in handins. If you do not have a preference, we will randomly assign a partner for you.

You will work with your partner on Assignment 4.

Goals: The goals of this lab are to learn how to design and use abstract classes, and to solve problems with the use of accumulators.

Submission: (Due by the end of your lab period) Submit your solutions to Problem 1. You may work with your new partner on this, but the submission is individual. This will be graded on effort and good design. Problem 2 is extra practice, but highly recommended.

Problem 1: Tasks and abstraction

Related files:
  ATaskStarter.java  

You are now extending the reminders program from Lab 3. You have decided to keep track of tasks specific to your classes. The following class diagram represents your updated task tracker system that records the class tasks you have to complete. For the purposes of this exercise, there are three kinds of class tasks: homework tasks, lab tasks, and in-class tasks.

All homework and lab tasks have 7 days to be completed, while in-class tasks only have 1 day to be completed. Homework tasks have a 10 percent deduction per day late, while other kinds of tasks have a 2 percent deduction per day late.

To update your program from Lab 3, each task still has its own description and an indication of whether the task has been completed or not. But now, each task also has a date created. Homework and lab tasks have a partner name representing who you are working with; in-class tasks are always individual, so it does not have a partner name.

The day when the task is created and the day it is due are counted as days since New Year’s Day in 2025. So, for example, a homework task created today would be recorded as created on day 35 with due date on day 42.

                    +-------+
                    | ITask |
                    +-------+
                       / \
                       ---
                        |
          -------------------------------------------------
          |                       |                       |
+--------------------+  +--------------------+  +--------------------+
| HomeworkTask       |  | LabTask            |  | InClassTask        |
+--------------------+  +--------------------+  +--------------------+
| String description |  | String description |  | String description |
| boolean isDone     |  | boolean isDone     |  | boolean isDone     |
| int dateCreated    |  | int dateCreated    |  | int dateCreated    |
| String partnerName |  | String partnerName |  +--------------------+
+--------------------+  +--------------------+

For all methods, think carefully whether they should be designed being implemented solely in the abstract class, implemented solely in the concrete classes, or implemented in the abstract class and then overridden in some of the concrete classes.

Problem 2: Problem Solving Practice

The rest of the lab will be dedicated to strengthening problem solving skills, in particular the use of accumulators. It will require you to create new classes as well as determine what helper methods would be appropriate.