Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Programming Assignment

You to write a class named WeaklyCalendar. This class must be in a package named pa4.

Note that the description of a programming assignment is not a linear narrative and often requires multiple readings before things start to click. You are encouraged to consult instructors/Teaching Assistants for any questions/clari?cations regarding programming assignments. 1 Calendar You will be writing a program to implement a baby version of Google calendar/iCal to keep track of appointments. A Calendar program stores all appointments, and you can add an appointment to the calendar, or delete an existing appointment. For our purposes, we work with weekly calendar

(not monthly/yearly calendars).

An appointment has two ?elds: Day of the appointment, time of the appointment. Suppose you have an appointment on Monday at 5PM. This information can be represented as string of the form "Monday@5PM". Similarly an appointment on Tuesday at 8AM can be represented with the string "Tuesday@8AM".

For the sake of this program we make some simplifying assumptions. Every appointment starts at the top of the hour, and lasts for at most one hour. For example, we do not allow appointments that start at 5:30PM, nor we allow appointments that start at 6AM and end at 8AM.

All the data about appointments is initially stored in a text ?le named myCalendar.txt. This ?le consists of words and each word describes an appointment. Here is a sample contents of the ?le Monday@5PM, Tuesday@2PM andFriday@6PM.

Note that each appointment is described by a single word.

Your task is to write a program that reads the appointment data from the ?le named myCalendar.txt.

Once it reads the data from this ?le, the program interacts with the user. The user can add an appointment, remove and appointment or print the calendar on the screen etc. 2 Your Task Your task is to a write program named WeeklyCalendar that keeps track of all appointments. For this you will be writing several methods. Your program must have the following method. readFromFile. This method reads appointments from a ?le named myCalendar.txt. This ?le is stored in the projects folder. The format of the ?le is as described above. This method returns an 1 array list of Strings. Each word of the ?le myCalendar.txt will be an element of the array list. For example if the contents of the ?le are as described above, then this method returns an array list (of Strings) of size 3. The string at index 0 is "Monday@5PM", String at index 1 is "Tuesday@2PM", and String at index 2 is "Friday@6PM". From now we will refer to this list as appointment list.

hasAppointmentAt. This method takes three parameters with following names and types.

• appointmentList. This is an array list of strings that represents all appointments.

• specifiedDay. A string representing weekday.

• specifiedTime A string representing time. This of form "hhAM" or "hhPM". For example, "9AM" or "10PM".

This method searches appointmentList for an appointment on specifiedDay at specifiedTime.

If found, the method returns true. Otherwise, the method returns false.

addAppointment. This method takes three parameters with following names and types.

• appointmentList. This is an array list of strings representing all appointments.

• specifiedDay. A string representing weekday.

• specifiedTime A string representing time. This of form "hhAM" or "hhPM".

This method ?rst searches whether there already exists an appointment at specifiedTime on specifiedDay. If so, then this method returns false. Otherwise, this method adds appointment to the appointmentList and returns true removeAppointment. This method takes three parameters with following names and types.

• appointmentList. This is an array list of strings representing all appointments.

• specifiedDay. A string representing weekday.

• specifiedTime A string representing time. This of form "hhAM" or "hhPM".

This method ?rst searches appointmentList whether there is appointment at specifiedTime on specifiedDay. If so, then this method removes that appointment and returns true. Otherwise, this method returns false.

appointmentsOnDay. This method takes two parameters with following names and types.

• appointmentList. This is an array list of strings representing all appointments.

• specifiedDay. A string representing a week day.

This method returns an array list (of Strings) consisting of all appointments on specifiedDay.

printAppointmentCalendar. This method takes a variable named appointmentList (which is an array list of Strings) representing all appointments, and prints all appointments of the week on the screen. Each line of the output starts with weekday followed by appointments on that day. Since there are seven weekdays, the output has 7 lines. An example output is as follows:

2 Monday: 2PM 8AM 3PM

Tuesday:

Wednesday: 11AM 12PM

Thursday: 2PM 8AM 11AM

Friday:

Saturday: 9AM 10AM 12PM 5PM 8PM

Sunday:

main. This is the main method. The main method ?rst reads the appointments from a ?le named myCalendar.txt and stores them in an array list (by calling the method readFromFile). Then it repeatedly prompts the user to enter one of "addAppointment", "removeAppointment", "printDay", "printAll" or "quit" until user enters "quit". For each of the responses that user enters, the program behaves as follows:

addAppointment. Prompts the user to enter day and time of appointment to be added(day must be a weekday, and time is of the form "hhAM", or "hhPM"). If there is already another appointment at that time and day then display a message saying so. If there is no appointment at that time and day, then adds the appointment.

removeAppointment. Prompts the user to enter day and time of appointment to be deleted(day must be a weekday, and time is of the form "hhAM", or "hhPM"). If there is no appointment at that time and day, then displays a message saying so. If there is an appointment at that time and day then deletes the appointment.

printDay. Prompts the user to enter a weekday and prints all appointments on that day.

printAll. Prints all appointments for the entire week.

quit. Program terminates.

Below is a sample run of the program. Boldface text indicates user input.

Please enter one of the following:

addAppointment, removeAppointment, printDay, printAll, quit

addAppointment

Enter day and time

Friday 8AM

There is another appointment at that time, can not add.

Please enter one of the following:

addAppointment, removeAppointment, printDay, printAll, quit

addAppointment

Enter day and time

Tuesday, 1PM

Added Appointment 3 Please enter one of the following:

addAppointment, removeAppointment, printDay, printAll, quit

removeAppointment

Enter day and time

Thursday 2PM

Removed appointment

Please enter one of the following:

addAppointment, removeAppointment, printDay, printAll, quit

removeAppointment

Enter day and time

Friday 2PM

No appointment at that time, can not remove.

Please enter one of the following:

addAppointment, removeAppointment, printDay, printAll, quit

printDay

Enter weekday

Thursday

Thursday Appointemnts: 2PM 8AM 10PM

Please enter one of the following:

addAppointment, removeAppointment, printDay, printAll, quit

printAll

Weekly Calendar:

Monday: 8AM

Tuesday: 10AM 9AM 12PM

Wednesday: 2PM

Thursday:

Friday: 8AM

Saturday: 9AM 11AM 5PM

Sunday: 10AM

Please enter one of the following:

addAppointment, removeAppointment, printDay, printAll, quit

quit

Quitting. 3 User Input You may assume that the user always enters a valid input. For example, when prompted for weekday, the user enters one of the weekdays. When prompted for time user enters time in the format "hhAM" or "hhPM". For example, the user will not enter an input of the form 930AM.

4 4 String methods You may ?nd the following string methods useful: indexOf, substring, length and String concatenation. 5 Coding Conventions You must follow good coding conventions. Variable names must be meaningful, variable names (and method names) must start with lower case letters, code must be properly indented. Your code must have appropriate comments. Failure to follow good coding conventions will cause you to lose points (even if your solution is correct). 6 Suggestions Do not attempt to write code for all the methods at once. Write one method at a time, test that the method works correctly then proceed to the next method. 7 Speci?cations You must follow the speci?cations exactly. Your program must be named WeeklyCalendar and should be in a package named pa4. Please note that Java is case-sensitive. The input-output behavior of your program must be exactly as described. Failure to follow the speci?cations (even if your solution is correct) will cause you to lose points. Submit WeeklyCalendar.java via blackboard.

Java, Programming

  • Category:- Java
  • Reference No.:- M92058875
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As