factory method, Software Engineering

For this assignment you will create a program called MMWordFix (Multi-Mode WordFix). This program prompts the user to select one of three word filters (uppercase, lowercase, encrypt). Then it allows the user to repeatedly apply this filter either interactively or to convert a file. Here is a sample run:


If the user tries to convert a file and the file is not found in the local directory, they should see an error message, e.g.:


If the user does not correctly enter the name of one of the filters, WordFix should continue to prompt the user until a valid selection is entered. For example,



This program builds on Hwk4.
IFilter, FUpperCase, FLowerCase, FEncrypt:
• No changes.
FilterMgr:
• Change method selectFilter to return a pointer to IFactory. Thus it creates and returns an instance of the appropriate factory (instead of filter).
IFactory:
• An interface that has method NewFilter, which takes no arguments and returns a pointer to an IFilter.
UCaseFactory, LCaseFactory, EncryptFactory:
• Each implements interface IFactory.
• Each creates a different type of filter object: FUpperCase, FLowerCase, or FEncrypt respectively.
InteractiveFix:
• Has private attribute myFilter, which is a pointer to an IFilter.
• The constructor takes a pointer to an IFactory as an argument. It uses the factory object to create a filter object, which it saves in myFilter.
• Has method DoInteractiveSession, which takes no arguments and returns nothing. This method:
o Prompts the user for a word, then accepts a word from the user.
o If the word is “q”, the method returns.
o Otherwise it executes myFilter on the word, and displays the result.
• Note that InteractiveFix should not know anything about specific factory or filter classes; it only knows about IFactory and IFilter.
FileFix:
• Has private attribute myFactory, which is a pointer to an IFactory.
• The constructor takes a pointer to an IFactory as an argument. It saves the factory object in myFactory.
• Has method ConvertFile, which takes string argument and returns nothing. The argument is the name of the input file. This method:
o Uses myFactory to create the appropriate filter object.
o Opens the input file and output file (same name but .fix suffix).
o Reads each line in the input file, converts it, and writes it to the output file.
o Closes both files.
• Note that FileFix should not know anything about specific factory or filter classes; it only knows about IFactory and IFilter.
main():
• Prompts the user for a filter name, using the FilterMgr to get the choices.
• Accepts a filter name from the user.
• If the filter name is “q”, the program quits.
• Uses the FilterMgr to get the appropriate factory object that can create the named filter. If the filter name is not one of the available filters, the user is prompted again.
• Now the user may repeatedly apply the filter in one of two modes.
o Prompt the user for the mode (“i” or “f”)
o If the mode is “q”, the program quits.
o If the mode is “i”, an InteractiveFix object is created and used to apply the filter interactively.
o If the mode is “f”, the user is prompted for a file name then a FileFix object is created and used to apply the filter to a file.
• Note that main() should not know about any of the specific factory classes; it only knows about IFactory.
• Note that main() should not know anything about filters.
Posted Date: 10/28/2012 7:55:37 PM | Location : United States







Related Discussions:- factory method, Assignment Help, Ask Question on factory method, Get Answer, Expert's Help, factory method Discussions

Write discussion on factory method
Your posts are moderated
Related Questions
CMM = 'Capability Maturity Model', now known as the CMMI ('Capability Maturity Model Integration'), developed by the SEI. It's a model of five levels of process 'maturity' that ver

desidn a complete flow chart diagram ,which ask the user to input the rate of diesel and quantity of diesel consumed.after calculate the total amount of diesel consumed and display

Write down the concept of Functional independence.  a. Functional independence is gained by developing modules with "single minded" function and an "aversion" to extreme intera

What are the principle stages of VORD method? Viewpoint identification: Identify the services given to each viewpoint. Viewpoint structuring: Grouping linked viewpoints in t

Q. For the program given below, calculate the values of software science measures like ? , N, V, E and λ . int. sort (int x[], int n) { int i, j, save, im1; /

Q. Explain about Communicational cohesion? Communicational cohesion: The Communicational cohesion is when parts of a module are grouped for the reason that they operate on th

We discussed the importance of framing a problem in order to understand the problem better and be able to develop a solution more quickly and easily. In this homework, you are ask

I need help two thing 1-understand how can I programme rabbit 4000 2- do labs set for Rabbit 4000

Q. Explain Intermediate and Detailed COCOMO model? Intermediate COCOMO calculates software development effort as function of program size and a set of cost drivers that include

What is requirement engineering? Requirement engineering is the process of establishing the services that the customer needs from the system and the constraints under which it