Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this problem, you will be writing a Diary class that can record weekly appointments, like class meeting times, project meetings, lab sessions, etc. To

For this problem, you will be writing a Diary class that can record weekly appointments, like class meeting times, project meetings, lab sessions, etc. To do this, the Diary class maintains a 2-D array of time entries where rows represent the day of the week, and columns represent the hour of the day. We will only be storing 10 hours' worth of appointments, from 8am to 5pm. Before we can develop the Diary class, we need an Appointment class that is a blueprint for the various appointments that will be recorded in the Diary. Appointment Class (skeleton provided) Features:

1. Include two fields: an integer field representing the hour of the day at which the appointment occurs, and a string representing a description of the appointment. We will use military time to denote hours, so 0 represents midnight, 8 is 8:00am, 20 is 8:00pm, 23 is 11:00pm, etc.

2. Write a constructor that takes two parameters: one integer parameter for the time, followed by a string representing the description.

3. Write accessor methods called getDescription() and getHour() that return the description of an appointment and the hour at which that appointment occurs respectively.

4. Include mutator methods called setDescription() and setHour() that allow an appointment's description and time to be changed respectively. These mutators should each take a single argument.

5. Since we usually do not use military hour numbers to refer to times, it might be easier to create appointments if one could enter a time like "10pm" or "9am". To do this, add a new mutator called setTime() . This mutator should take a single string parameter that consists of an hour number followed by am or pm (no spaces between the hour number and am or pm). It will set the field inside the appointment by examining the characters of the string. Hint: Use the substring() provided by the String class to extract a new string containing only the digits and then use the Integer.parseInt() static method to convert the digits into the corresponding integer value.

6. Write a second constructor to the class that takes two string parameters: first, a string representing the time (non-military style), and then a string representing the appointment description. This new constructor can call the mutator method you just created to do part of its work.

7. Add a toString() method returning a String value. This method is included to print the appointments in a more readable format as given below: 3pm: CS 211

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Have to Do: Stay the course while planning ahead.

Answered: 1 week ago