Program for storing information about telephone customers


Assignment Overview:

Develop a program that provides viewing, creating, and storing information about telephone customers.

You will need to author two classes – Customer and Pensioner. Pensioner must be a subclass of Customer. These classes must be in their own files with separate header files. Details are given below.

Create a third class called Manager. The manager file can hold the main function. The Manager class must holds member functions which read a text file, called telephone.dat, line by line, performing appropriate actions at each line, till the end of the file is reached. You must make no assumptions about the length of the file.

Each line of the file has the following format:
- Jimbo Jones 43215678 56
- Gladys Skinner 7628372 56 P P23435
D
P

The action for each line will depend on the first character (the directive).

- If the first character is “O” then there are two possibilities.

- The customer is an ordinary customer. In this case the fields are firstName, lastName, telephoneNo and numberOfCalls. A Customer object must be created and initialised with values from this line.

- The customer is a pensioner. In this case, we have a field P that purely signifies which we are dealing with a pensioner, followed by the pension number. A Pensioner object must be created with the four Customer fields and also the pension number.
In either case, the resulting object should be added to an array of ten Customer pointers called ‘store’.   This array should be a private data member of the Manager class.

- If the first character is “D” then the Customer or Pensioner object most recently added to the store must be removed. The way that the store must be handled is to create a second private data member called ‘top’ which is originally set to zero. Each time you add a Customer object you add it at the point signified by top. Top is then incremented. Therefore, the first Customer is put in position zero and top is incremented to 1. When we remove a Customer, we use top to determine which object to remove.

- If the first character is “P” then all of the elements in the array must be printed to a file (called CustomerOutput.dat). The output must be appended to the file – not overwrite what is already there. The deleted elements must, of course, not figure in this output. The output must hold all of the information for the Customer. Furthermore, a telephone charge should be calculated as the number of calls at 45c each. If the Customer is a pensioner then the pension number must be output and a discount of 10% provided. Both the discount and the new price must be displayed. Note: that the techniques for calculating the charge must be defined in Customer class and overridden in the Pensioner class. Polymorphism must be used rather than any attempt to explicitly determine what type of object is being dealt with.

- If the line holds only white space, it must be ignored and the program must proceed to the next line.

- If the directive contains any character other than those above an error message must be give and the program should continue.
The output to the file must be provided in both of two ways:

- A technique called print must be provided in both the Customer and Pensioner class

- The << operator should be overridden in both classes.
Error messages must be provided in the following situations:

- Incorrect directives in the input file

- Attempting to add a customer to a full store

- Attempting to delete a customer from an empty store

- Any other appropriate situations

In each of these cases, the error message must be given and the program must be allowed to continue. In your report, give your view on which is the best techniques in particular circumstances.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Program for storing information about telephone customers
Reference No:- TGS0968

Expected delivery within 24 Hours