Create a factory function and constructor, Computer Engineering

1) This project will use an account class that has the members:

string account_code;

string first_name;

string last_name;

double balance;

Provide a constructor that initializes ALL members in its initialization list with data passed in as arguments to the constructor.  You will also need accessor functions to get the account code and balance and to set the balance.

In addition, include two pure virtual functions that look like the following:

virtual void monthly_update() = 0;

virtual char type() = 0;

2) Design and implement the following derived classes that will inherit from account and implement the monthly_update function in the following manner: 

2058_Create a factory function.png

If the type is an 'X', skip the account record.  In other words, the account should not be processed by the rest of the program and should not appear in the result.

If the type is anything else, throw an invalid_account_type exception (that you will have to write), but DO NOT stop processing the rest of the accounts.  Instead, log the account to a file named "account.log". Trim spaces from the right of the first_name and last_name members.

4) Write a manager class that has a vector member and a main function.  In the main function, open an ifstream on the file, "account2.dat", which will be supplied to you.  If the file does not exist, throw a file_not_found exception (that you will have to write) and terminate the program after logging this to the "account.log" file.

5) For each account in the input file, invoke the factory function/class written in part

3)  Each object returned from the factory function will then be inserted into the vector. 

1874_Create a factory function1.png

If the account is to be ignored, or if the factory function throws an invalid_account_type exception, no account should be inserted into the vector (let alone even created).  At the end of the stream, proceed with part 6.

6) Iterate through the vector and invoke the monthly_update function for each account in the vector.

7) Using an ofstream, output each account to a new file named "update.dat" in the SAME format as "account2.dat".

8) Output the accounts in a "human readable format" to a file, "report.txt".  The output format is of your choice, but please include all the members of each account per line (including the type).

9) Write a main function that instantiates your manager class from part 4, invokes its main and takes care of any exceptions that could possibly "leak" out.

Posted Date: 3/1/2013 5:34:06 AM | Location : United States







Related Discussions:- Create a factory function and constructor, Assignment Help, Ask Question on Create a factory function and constructor, Get Answer, Expert's Help, Create a factory function and constructor Discussions

Write discussion on Create a factory function and constructor
Your posts are moderated
Related Questions
Data Mining is an analytic method designed to explore data and then to validate the findings by applying the detected patterns to latest subsets of data.  The ultimate goal of dat

Main script section ("Sub Main .. End Sub) and function bodies should fit within an A4-page (approx. two monitor-pages). If the code doesn't fit it is a candidate to do more decoup

I NEED THE CODES IN MATLAB FOR RESOURCE ALLOCATION IN GRID COMPUTING


Define interrupt. An interrupt is any exceptional event that causes a CPUU to temporarily transfer control from its present program to another program , an interrupt handler th

Q. Explain about disk caching scheme? The disk caching scheme can be used to speed up performance of disk drive system. A set (cache) of buffers is assigned to hold some disk b

Q. FORALL Statement in fortran? The FORALL statement permits for more common assignments to sections of an array. A FORALL statement has general form.   FORALL ( triplet, ..

Given the subsequent FIFO and rules, how deep does the FIFO require to be to stop underflow or overflow? RULES: a. frequency(clk_A) = frequency(clk_B) / 4 b. per

What is managed code and managed data? Managed code is code that is written to target the services of the Common Language Runtime. In order to target these services, the code m

The structure of Logical Databases reflects which dependencies of hierarchical tables in the SAP system. Foreign Key dependencies