Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a UML DIAGRAM for the program below. The code is below. And I took a picture of the instructions. package homework4; import java.util.ArrayList; import

Create a UML DIAGRAM for the program below. The code is below. And I took a picture of the instructions.

package homework4;

import java.util.ArrayList;

import java.util.Scanner;

abstract class Appointment{

private String description;

private String lastName;

private int hours=0;

private int minutes=0;

public void setDescription(String description){

this.description = description;

}

public void setLastName(String lastName){

this.lastName = lastName;

}

public void setHours(int hours){

this.hours = hours;

}

public void setMinutes(int minutes){

this.minutes = minutes;

}

public String getDescription(){

return this.description;

}

public String getLastName(){

return this.lastName;

}

public int getHours(){

return this.hours;

}

public int getMinutes(){

return this.minutes;

}

abstract public boolean occursOn(int year,int month,int day);

}

class Onetime extends Appointment{

private int year;

private int month;

private int day;

public void setYear(int year) {

this.year=year;

}

public void setMonth(int month) {

this.month=month;

}

public void setDay(int day) {

this.day=day;

}

public int getYear() {

return this.year;

}

public int getMonth() {

return this.month;

}

public int getDay() {

return this.day;

}

@Override

public boolean occursOn(int year, int month, int day) {

if(this.year==year && this.month==month && this.day==day)

return true;

return false;

}

}

class Daily extends Appointment{

@Override

public boolean occursOn(int year, int month, int day) {

// TODO Auto-generated method stub

return true;

}

}

class Monthly extends Appointment{

private int day;

public void setDay(int day) {

this.day=day;

}

public int getDay() {

return this.day;

}

@Override

public boolean occursOn(int year, int month, int day) {

if(this.day==day)

return true;

return false;

}

}

public class TestAppointmentss {

static Scanner sc= new Scanner(System.in);

public static void main(String[] args) {

ArrayList al = new ArrayList();

System.out.println("How many appointments do you with to make?");

int num = sc.nextInt();

for(int i = 1;i

System.out.println("Please make a selection:");

System.out.println("1. One Time Appointment");

System.out.println("2. Daily Appointment");

System.out.println("3. Monthly Appointment");

int selection = sc.nextInt();

al.add(makeAppointment(selection));

}

System.out.println("*******!!!Thank you for making all your appointments!!!*********");

char choice='y';

while(choice=='y') {

System.out.println("What is the date you wish to look up in your Appointment's Calendar");

System.out.print("Enter the month: ");

int month=sc.nextInt();

System.out.print("Enter the day: ");

int day=sc.nextInt();

System.out.print("Enter the year: ");

int year=sc.nextInt();

System.out.println("On "+month+"/"+day+"/"+year+" you have the following appointments:");

for(Appointment a:al) {

boolean isPresent=checkAppointment(a,year,month,day);

if(isPresent) {

System.out.println(a.getDescription()+" with "+a.getLastName()+" at "+a.getHours()+":"+a.getMinutes());

}

}

System.out.println("Do you wish to look up another date?");

choice=sc.next().charAt(0);

}

System.out.println("Thank you for using Appointment Calendar.");

}

public static Appointment makeAppointment(int selection) {

Appointment app=null;

String description="";

String lastName="";

int hours=0;

int minutes = 0;

int day=0;

int year=0;

int month=0;

sc.nextLine();

switch (selection) {

case 1:

Onetime onetime=new Onetime();

System.out.println("What is the description of your appointment?");

description = sc.nextLine();

System.out.println("What is your person's name?");

lastName = sc.nextLine();

System.out.println("What is the year of your appointment?(2017-2018)");

year = sc.nextInt();

System.out.println("What is the month of your appointment?(1-12)");

month = sc.nextInt();

System.out.println("What is the day of your appointment?(1-31)");

day = sc.nextInt();

System.out.println("What is the hour of your appointment?(1-31)");

hours = sc.nextInt();

System.out.println("What is the minutes of your appointment?(1-31)");

minutes = sc.nextInt();

onetime.setDescription(description);

onetime.setHours(hours);

onetime.setLastName(lastName);

onetime.setMonth(month);

onetime.setMinutes(minutes);

onetime.setYear(year);

onetime.setDay(day);

System.out.println("Appointment added with "+lastName+" on "+month+"/"+day+"/"+year+" at "+hours+":"+minutes);

System.out.println();

return onetime;

case 2:

Daily daily = new Daily();

System.out.println("What is the description of your appointment?");

description = sc.nextLine();

System.out.println("What is your person's name?");

lastName = sc.nextLine();

System.out.println("What is the hour of your appointment?(1-31)");

hours = sc.nextInt();

System.out.println("What is the minutes of your appointment?(1-31)");

minutes = sc.nextInt();

daily.setDescription(description);

daily.setHours(hours);

daily.setLastName(lastName);

daily.setMinutes(minutes);

System.out.println("Appointment added with "+lastName+" Daily at "+hours+":"+minutes);

System.out.println();

return daily;

case 3:

Monthly monthly = new Monthly();

System.out.println("What is the description of your appointment?");

description = sc.nextLine();

System.out.println("What is your person's name?");

lastName = sc.nextLine();

System.out.println("What day of the month is your appointment?(1-12)");

day = sc.nextInt();

System.out.println("What is the hour of your appointment?(1-31)");

hours = sc.nextInt();

System.out.println("What is the minutes of your appointment?(1-31)");

minutes = sc.nextInt();

monthly.setDescription(description);

monthly.setHours(hours);

monthly.setLastName(lastName);

monthly.setMinutes(minutes);

monthly.setDay(day);

System.out.println("Appointment added with "+lastName+" Monthly on day "+day+" at "+hours+":"+minutes);

System.out.println();

return monthly;

default:

System.out.println("Invalid Choice..!!");

return app;

}

}

public static boolean checkAppointment(Appointment a, int year, int month, int day) {

return a.occursOn(year, month, day);

}

}

image text in transcribed

Using the diagram on pages 425&429, and the classes for this project, provided in the programming assignment, create a UML diagram of the Appointment hierarchy. The Appointment class is abstract,and all of its subclasses are concrete: Daily, Monthly, and Onetime. Note: Include all getters and setters for all attributes, even if the textbook doesn't have them. Also note, there is a polymorphic method in all the classes called occursOn(int year, int month, int day) that checks whether the appointment occurs on that date.. Also, italicize all abstract methods. To get FULL credit on UML and class hierarchy, make sure you use the optimal hierarchical structure, with the most general class on top, followed by a more specific subclass, and if applicable an even more specific subclass. Also, re-use the toString() methods in the superclasses, such that each toString() method adds a little more detail than what the super class had. UML of Appointment Hierarchy Criteria Ratings Pts 25.0 pts Appointment abstract superclass, and its 3 concrete subclasses of Daily, Monthly, and Onetime. Attributes of description, yyyy, mm, dd are placed in the apropriate super and subclasses. The setDescription() method is defined at the super class level, since it is common to all classes. 50.0 pts Novice 0.0 pts Proficient 50.0 pts public setters and getters for each of the attributes. 10.0 pts Novice 5.0 pts Competent 0.0 pts Proficient 10.0 pts occursOn() method must be defined polymorphically for each subclass, receiving yyy mm dd as parameters. 20.0 pts Novice 10.0 pts Competent 0.0 pts Proficient 20.0 pts constructor in each subclass must be tailored to that subclass' instance variables. 20.0 pts Novice 10.0 pts Competent 0.0 pts Proficient 20.0 pts Using the diagram on pages 425&429, and the classes for this project, provided in the programming assignment, create a UML diagram of the Appointment hierarchy. The Appointment class is abstract,and all of its subclasses are concrete: Daily, Monthly, and Onetime. Note: Include all getters and setters for all attributes, even if the textbook doesn't have them. Also note, there is a polymorphic method in all the classes called occursOn(int year, int month, int day) that checks whether the appointment occurs on that date.. Also, italicize all abstract methods. To get FULL credit on UML and class hierarchy, make sure you use the optimal hierarchical structure, with the most general class on top, followed by a more specific subclass, and if applicable an even more specific subclass. Also, re-use the toString() methods in the superclasses, such that each toString() method adds a little more detail than what the super class had. UML of Appointment Hierarchy Criteria Ratings Pts 25.0 pts Appointment abstract superclass, and its 3 concrete subclasses of Daily, Monthly, and Onetime. Attributes of description, yyyy, mm, dd are placed in the apropriate super and subclasses. The setDescription() method is defined at the super class level, since it is common to all classes. 50.0 pts Novice 0.0 pts Proficient 50.0 pts public setters and getters for each of the attributes. 10.0 pts Novice 5.0 pts Competent 0.0 pts Proficient 10.0 pts occursOn() method must be defined polymorphically for each subclass, receiving yyy mm dd as parameters. 20.0 pts Novice 10.0 pts Competent 0.0 pts Proficient 20.0 pts constructor in each subclass must be tailored to that subclass' instance variables. 20.0 pts Novice 10.0 pts Competent 0.0 pts Proficient 20.0 pts

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

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

How do you talk about your complaining customers?

Answered: 1 week ago