Do that with C++ and please add more comment that make it understandable
#include <List>
#include <iostream>
#include <string>
#include <algorithm>
class Event
{
int m_hour;
int m_day;
int m_month;
int m_year;
static int id;
int m_id;
public:
Event(int hour, int day, int month, int
year):m_hour(hour),m_day(day),m_month(month),m_year(year)
{
m_id = id++;
}
virtual void print() = 0;
int getId()
{
return m_id;
}
int getDay()
{
return m_day;
}
int getHour()
{
return m_hour;
}
int getMonth()
{
return m_month;
}
int getYear()
{
return m_year;
}
};
int Event::id = 0;
class Task:public Event
{
std::string m_taskname;
public:
Task(std::string taskName, int hour, int day, int
month, int year)
:m_taskname(taskName),Event(hour,day,month,year)
{
}
void print()
{
std::cout << "Task with id "
<< getId() << " at " << getDay() << "/"
<< getMonth() << "/" << getYear() << ","
<< getHour() << ":00;" << std::endl;
std::cout <<
m_taskname;
std::cout << std::endl;
}
};
class Appointment :public Event
{
std::string m_personName;
public:
Appointment(std::string personName, int hour, int day,
int month, int year) :m_personName(personName), Event(hour, day,
month, year)
{
}
void print()
{
std::cout << "Appointment
with id " << getId() << " at " << getDay()
<< "/" << getMonth() << "/" << getYear()
<< "," << getHour() << ":00;" <<
std::endl;
std::cout <<
m_personName;
std::cout << std::endl;
}
};
class Calendar
{
std::list<Event*> m_listofEvents;
public:
Event* addEvent(int eventType, int year, int month,
int day, int hour)
{
static int count = 0;
Event* anEvent = nullptr;
switch(eventType)
{
case 0:
{
count++;
std::string
taskName;
std::cout
<< "Enter the Task Name for Task "<<count<<"
";
std::getline(std::cin, taskName);
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
anEvent = new
Task(taskName, hour, day, month, year);
break;
}
case 1:
{
count++;
std::string
personName;
std::cout
<< "Enter the Person Name for Appointment" <<
count<<" ";
std::getline(std::cin, personName);
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
anEvent = new
Appointment(personName, hour, day, month, year);
break;
}
default:
break;
}
m_listofEvents.push_back(anEvent);
return anEvent;
}
void deleteEvent(int id)
{
m_listofEvents.remove_if([&](Event* anEvent)->bool {
return
(anEvent->getId() == id);
});
}
void listEvents()
{
for (Event* anEvent :
m_listofEvents)
{
if
(anEvent)
anEvent->print();
}
}
void filterEvents(int year, int month)
{
for (Event* anEvent :
m_listofEvents)
{
if
((anEvent->getMonth() == month)
&& (anEvent->getYear() ==
year))
{
anEvent->print();
}
}
}
};
void main()
{
Calendar calendar;
calendar.addEvent(0, 2019, 4, 10, 23);
calendar.addEvent(0, 2019, 5, 6, 22);
calendar.addEvent(0, 2019, 4, 5, 20);
calendar.addEvent(0, 2019, 2, 19, 19);
calendar.addEvent(0, 2019, 5, 1, 21);
calendar.addEvent(1, 2019, 4, 1, 23);
calendar.addEvent(1, 2019, 5, 16, 22);
calendar.addEvent(1, 2019, 4, 15, 20);
calendar.addEvent(1, 2019, 2, 9, 19);
calendar.addEvent(1, 2019, 5, 1, 21);
std::cout << "\n Listing Events \n";
calendar.listEvents();
calendar.deleteEvent(3);
std::cout << "\n Listing Events after Filtering \n";
calendar.filterEvents(2019, 4);
}
OUTPUT:
In this hormework, you will implement a simple caledar application The implernentation shauld inc...
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...
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...
You are to create a class Appointment.java that will have the following: 5 Instance variables: private String month private int day private int year private int hour private int minute 1 default constructor public Appointment() 1 non-default constructor that accepts arguments for all instance variables, your constructor must call the setter methods below to set the values of the instance variables public Appointment(String monthPassed, int dayPassed, int yearPassed, int hourPassed, int minutePassed) 5 setter methods (one for each instance variable)...
The class dateType is designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and the year are checked before storing the date into the data members. Add a function member, isLeapYear, to check whether a year is a leap...
Design and implement a C++ class called Date that has the following private member variables month (int) day (nt) . year (int Add the following public member functions to the class. Default Constructor with all default parameters: The constructors should use the values of the month, day, and year arguments passed by the client program to set the month, day, and year member variables. The constructor should check if the values of the parameters are valid (that is day is...
C++ This exercise will introduce static member variables and static methods in class to you. Class Department contain information about universities departments: name students amount in addition it also stores information about overall amount of departments at the university: departments amount class Department { public: Department(string i_name, int i_num_students); ~Department(); int get_students(); string get_name(); static int get_total(); private: string name; int num_students; static int total_departments; }; Carefully read and modify the template. You have to implement private static variable "total...
c++ Part 1 Consider using the following Card class as a base class to implement a hierarchy of related classes: class Card { public: Card(); Card (string n) ; virtual bool is_expired() const; virtual void print () const; private: string name; Card:: Card() name = ""; Card: :Card (string n) { name = n; Card::is_expired() return false; } Write definitions for each of the following derived classes. Derived Class Data IDcard ID number CallingCard Card number, PIN Driverlicense Expiration date...
C++ Practice: Answer Whichever you can & it'll help a lot. Thank you! Question 1. Implement the constructors and member function of each of the classes (Marks 15) class Fraction{ private: int numerator; int denominator; public: Fraction(int, int); float fractionValue();//determines the value of numerator/denominator }; class Problem{ private: Fraction f[3]; public: Problem(int, int, int, int, int, int); Fraction largestFraction();//Returns the fraction having largest fraction value }; Question 2: In the following Inheritance problem #include<iostream> #include<string> using namespace std; class Animal{...
Create a class called Flower. Add one member variables color. Add only one getter function for the color. The get function returns color. Implement a constructor that expects color value and assigns it to the member variable. Create a subclass of Flower named Rose. The Rose class has one member variable name. Add a constructor which expects color and name. Pass color to the base constructor and set name to it's member variable.Write a program that has an array of ...
C++ Could you check my code, it work but professor said that there are some mistakes(check virtual functions, prin() and others, according assignment) . Assignment: My code: #include<iostream> #include<string> using namespace std; class BasicShape { //Abstract base class protected: double area; private: string name; public: BasicShape(double a, string n) { area=a; name=n; } void virtual calcArea()=0;//Pure Virtual Function virtual void print() { cout<<"Area of "<<getName()<<" is: "<<area<<"\n"; } string getName(){ return name; } }; class Circle : public...