Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Class Factory - Activity Scheduler

For this assignment you will modify the Activity Scheduler program, changing it to use the Class Factory design pattern. The behavior of the program is exactly as before. The structure of the new program is shown below:

1103_figure3.jpg

As before, assume that the user will enter the correct type of input in response to the prompts.

Classes IActivity, Activity, Name, LanId, and PhoneNumber

These classes are the same as before.

Class ScheduledActivity

This class is almost the same as before, except that now it both creates and destroys the IActivity objects:
- The constructor argument is now a pointer to a Factory object (not a pointer to an IActivity object). The constructor does exactly what it did before, except that it sets the attribute ‘activity' by invoking the Factory method NewActivity() (instead of setting it from the argument).
- The destructor now deletes the attribute ‘activity'.

Class Scheduler
This class is almost the same as before, except that it passes Factory objects to ScheduledActivity:
- Method addActivity() now takes a parameter that is a Factory* (instead of an IActivity*). It passes this parameter to the ScheduledActivity constructor.

Class Factory
This class is the interface for the four subclasses below. It has the following:
- A pure virtual method NewActivity(), which returns an IActivity*.
- A virtual destructor with an empty implementation (provided in the class declaration).

Classes ActivityFactory, LanIdFactory, NameFactory, and PhoneNumberFactory
These four classes implement interface Factory. Each provides an implementation of method NewActivity(), returning a new object of the appropriate type. (For example, ActivityFactory::NewActivity() returns a new Activity object, LanIdFactory::NewActivity() returns a new LanId object, etc.)

File MainControl.cpp, method main
This method is simpler than before, since it is no longer responsible for creating and destroying activities. Instead it creates four Factory objects (NameFactory, LanIdFactory, PhoneNumberFactory, and ActivityFactory). It passes each of these to the scheduler's addActivity() method, and deletes all four Factory objects. Then it calls the scheduler's run() method, and returns 0.

General Information
Make sure you follow all coding conventions.

Make sure you have no memory leaks: delete any objects that are no longer reachable by any pointer.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92040295

Have any Question?


Related Questions in Computer Engineering

A sample of 40 songs from a students itunes playlist showed

A sample of 40 songs from a student's iTunes playlist showed a mean length of 3.542 minutes with a standard deviation of 0.311 minute. Construct a 95% confidence interval for the population standard deviation.  (Round yo ...

Taylor found that 8 of the recipients of loans form a

Taylor found that 8% of the recipients of loans form a particular mortgage lender default within 3 years. If he takes a random sample of 736 customers who received loans 3 years ago, what is the average number of custome ...

A mixture of 499 mol of n2 and 3090 g of no is heated in a

A mixture of 4.99 mol of N2 and 30.90 g of NO is heated in a closed vessel to 2000 °C. After heating, the total pressure of the mixture at equilibrium is 3.14 atm. N2(g) + O2(g) 2NO(g) Kp= .101 at 2000 C In which directi ...

How does westpac manage foreign exchange risk how does it

How does Westpac manage foreign exchange risk? How does it differ to the other 4 big banks? (ANZ, CBA and NAB)

Question three academically reviewed articles on management

Question: Three academically reviewed articles on Management Information Systems and complete the following activities: 1. Summarize all three (3) articles in 600 words or more in APA format with reference 2. Discuss at ...

Explain that our ability to secure each computers stored

Explain that our ability to secure each computers stored information is now influenced by the security on each computer to which it is connected

In a large university 6 of students live in dormitories a

In a large university, 6% of students live in dormitories. A random sample of 14 students is selected. What is the probability that the sample contains more than five students who do not live in the dormitories?

1 select one of the topics listed below and discuss

1. Select one of the topics listed below and discuss it. Describe an application that you have to solve by using at least 2 Excel functions. It can be Math, Statistics, Engineering, Financial, etc. Explain what Excel fun ...

Configuring name resolutionas the administrator of the

Configuring Name Resolution As the administrator of the Contoso Corporation, you manage an internal website that is often used by most users with the company. You try to connect to an internal website but cannot open the ...

What is the current balance of trade for the united states

What is the current balance of trade for the United States? Has this balance been increasing or decreasing? Based on the current economic conditions, how do you think this balance will move in the near future, and why?

  • 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