Customer and Pensioner. Pensioner should be a subclass of Customer. These classes should be in their own files with separate header files. Details are below.

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

Each line of the file has the following format:

A Jimbo Jones 43215678 56
A Gladys Skinner 7628372 56 P P23435

Recommended Answers

All 4 Replies

Customer and Pensioner. Pensioner should be a subclass of Customer. These classes should be in their own files with separate header files. Details are below.

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

Each line of the file has the following format:

A Jimbo Jones 43215678 56
A Gladys Skinner 7628372 56 P P23435

And the question is???

And the question is???

• If the first character is A then there are two possibilities.
o The customer is an ordinary customer. In this case the fields are firstName, lastName, telephoneNo and numberOfCalls. A Customer object should be created and initialised with the values from this line.
o The customer is a pensioner. In this case, we have a field P which purely signifies that we are dealing with a pensioner, followed by the pension number. A Pensioner object should 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 should be deleted. The way that the store should 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. Thus, the first Customer is put in position zero and top is incremented to 1. When we delete a Customer, we use top to determine which object to remove.
• If the first character is O then all of the elements in the array should be printed to a file (called CustomerOutput.dat). The output should be appended to the file – not overwrite what is already there. The deleted elements should, of course, not figure in this output. The output should contain 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 should be output and a discount of 10% provided. Both the discount and the new price should be displayed. Note: that the methods for calculating the charge should be defined in the Customer class and overridden in the Pensioner class. Polymorphism should be used rather than any attempt to explicitly determine what type of object is being dealt with.
• If the line contains only white space, it should be ignored and the program should proceed to the next line.
• If the directive contains any character other than those above an error message should be give and the program should continue.

The output to the file should be provided in both of two ways:
• A method called print should be provided in both the Customer and Pensioner class
• The << operator should be overridden in both classes.

Error messages should be provided in the following circumstances:
• 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 should be given and the program allowed to continue.

In your report, give your opinion on which is the best technique in this particular circumstance

• If the first character is A then there are two possibilities.
o The customer is an ordinary customer. In this case the fields are firstName, lastName, telephoneNo and numberOfCalls. A Customer object should be created and initialised with the values from this line.
o The customer is a pensioner. In this case, we have a field P which purely signifies that we are dealing with a pensioner, followed by the pension number. A Pensioner object should 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 should be deleted. The way that the store should 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. Thus, the first Customer is put in position zero and top is incremented to 1. When we delete a Customer, we use top to determine which object to remove.
• If the first character is O then all of the elements in the array should be printed to a file (called CustomerOutput.dat). The output should be appended to the file – not overwrite what is already there. The deleted elements should, of course, not figure in this output. The output should contain 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 should be output and a discount of 10% provided. Both the discount and the new price should be displayed. Note: that the methods for calculating the charge should be defined in the Customer class and overridden in the Pensioner class. Polymorphism should be used rather than any attempt to explicitly determine what type of object is being dealt with.
• If the line contains only white space, it should be ignored and the program should proceed to the next line.
• If the directive contains any character other than those above an error message should be give and the program should continue.

The output to the file should be provided in both of two ways:
• A method called print should be provided in both the Customer and Pensioner class
• The << operator should be overridden in both classes.

Error messages should be provided in the following circumstances:
• 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 should be given and the program allowed to continue.

In your report, give your opinion on which is the best technique in this particular circumstance

Thanks for clarifying. I'll get right on that. :icon_rolleyes:

Are you asking the forum to do your homework for you?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.