Here the two classes "Event.java" and "DateBook.java":
Event.java:
public class Event {
private String StartingTime;
private String Name;
private int Priority;
public String getStartingTime() {
return StartingTime;
}
public void setStartingTime(String startingTime) {
StartingTime = startingTime;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public int getPriority() {
return Priority;
}
public void setPriority(int priority) {
Priority = priority;
}
}
DateBook.java:
import java.util.ArrayList;
import java.util.Collections;
public class DateBook {
public static void main(String[] args) {
Event[] september = new Event[30];
Event[] october = new Event[31];
int startingDayOfSeptember = (int)(Math.random()*6);
int startingDayOfOctober = (startingDayOfSeptember+30)%7;
showEvents(september, startingDayOfSeptember);
System.out.println("\n\n");
showEvents(october, startingDayOfOctober);
}
public static void showEvents(Event[] month, int startingDay)
{
String[] nameOfEvents = {"Birthday","Anniversary","Marriage","Engagement"};
int temp=0;
//Get the unique dates for events
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i=0; i<month.length; i++) {
list.add(new Integer(i));
}
Collections.shuffle(list);
for (int i=0; i<10; i++) {
int eventDate = list.get(i); // event date
month[eventDate]= new Event();
month[eventDate].setName(nameOfEvents[(int)(Math.random()*3)]+" #"+((int)(Math.random()*100)+1));
month[eventDate].setStartingTime(((int)(Math.random()*12)+1)+":00 PM");
month[eventDate].setPriority((int)(Math.random()*3+1));
}
//Print Calendar
System.out.println("Sun\tMon\tTue\tWed\tThu\tFri\tSat");
for (int i=0; i<month.length; i++) {
if(i < startingDay)
{
System.out.print("\t");
temp++;
continue;
}else
break;
}
int tempBreakLine = temp;
for (int i=0; i<month.length; i++) {
tempBreakLine++;
if(month[i]!=null)
{
System.out.print(i+1+"*\t");
}
else{
System.out.print(i+1+"\t");
}
if(tempBreakLine%7 == 0) {System.out.println();}
}
System.out.println("\n");
System.out.println("Events:");
for (int i=0; i<month.length; i++) {
if(month[i]!=null)
{
System.out.print((i+1)+": "+ month[i].getStartingTime()+": "+month[i].getName()+": (priority "+month[i].getPriority()+")");
System.out.println();
}
}
System.out.println();
System.out.println("High-priority events:");
for (int i=0; i<month.length; i++) {
if(month[i]!=null && month[i].getPriority() == 3)
{
System.out.print((i+1)+": "+month[i].getName());
System.out.println();
}
}
}
}
OutPut:
PART B: DATE BOOK A classic computer application is the electronic date book: a list of...
Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...
Create a class called Date212 to represent a date. It will store the year, month and day as integers (not as a String in the form yyyymmdd (such as 20161001 for October 1, 2016), so you will need three private instance variables. Two constructors should be provided, one that takes three integer parameters, and one that takes a String. The constructor with the String parameter and should validate the parameter. As you are reading the dates you should check that...
In C++
array. It should use an int numEvents' to keep track of how many events have been entered in the array. An event should be represented by a struct with several member variables. An event Strings for a name, description, and notes A date and time represented by their own structs. The Date struct should contain an int day, string month, and int year, and the Time struct should contain an int hour, int minute, int second, and bool...
Design "MyWeek" class: (1) Data members: the class contains one private data field weekList. "weekList" has datatype of ArrayList, which will contain String objects of week/weekend days. There are no duplicated days in the list. Valid days are "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun". The weekList is not necessarily to be ordered (2) Constructors The instance of MyWeek can be constructed with (a) no argument (initialized weekList to empty), or (b) with one String argument which is one valid...
its about in C++
You will implement a simple calendar application The implementation should include a class named Calendar, an abstract class named Event and two concrete classes named Task and Appointment which inherit from the Event class The Event Class This will be an abstract class. It will have four private integer members called year, month, day and hour which designate the time of the event It should also have an integer member called id which should be a...
Instructions: Refer to the Timel class provided in Figure 8.1 in your Deitel book to complete the exercise. Make sure that you follow the Program Style and Readability guidelines found in the Start Here Folder. 1. Write a Point class. The Point class should be written as an abstract data type. 2. Include the following instance variables: a. an integer representing the x coordinate b. an integer representing the y coordinate c. The instance variables in your program should only...
//Please help me out with this problem.. This problem has to be
done in C++ and has to strictly follow the instructions... I have
given the expected output of the problem
below.
1) Design a class Date: Provide 3 instance variables (int) to store the month, the day number, and the year Provide the following functions Default constructor -sets date to, 1500 Constructor with parameters - if parameters are not valid, set like default constructor setDate if parameters are not...
Do that with C++ and please add more comment that make
it understandable
In this hormework, you will implement a simple caledar application The implernentation shauld include a class narned Calendar, an abstract class named Event and two concrete classes narmed Task and Appointment which irherit from the Evernt class. The Event Class This will be an abstract class. It will have four private integer members called year, month, day and hour which desigate the tirne of the event. It...
Need Help finishing up MyCalendar Program: Here are the methods: Modifier and Type Method Description boolean add(Event evt) Add an event to the calendar Event get(int i) Fetch the ith Event added to the calendar Event get(java.lang.String name) Fetch the first Event in the calendar whose eventName is equal to the given name java.util.ArrayList<Event> list() The list of all Events in the order that they were inserted into the calendar int size() The number of events in the calendar java.util.ArrayList<Event>...
**Only need the bold answered Implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class must be in separate file. Draw an UML diagram with the inheritance relationship of the classes. 1. The Athlete class a. All class variables of the Athlete class must be private. b.is a class with a single constructor: Athlete(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender). All arguments of the constructor should be stored as class variables. There should only...