$30
Scenario
You are part of a team working on a new application. The application, called “Info Tracker” is designed to help people keep track of personal information. There are other products like this on the market. The difference in this application is that it is extendable using plug-in modules to support different types of information that people want to record.
At the moment, the interfaces have been designed and the initial version of the main application has been written. One plug-in has been written in order to test the main application. When run, the application looks something like the following (note that you will not see any cards in the list when you run it since no file has been created yet):
In the left-hand pane, there is a tree of categories and, under that category; there are pieces of information (known as Info Cards in the application). In the example above, you can see three categories – Note, Credit Card and Password. If you double-click on one of the Info Cards, you will see the information associated with that card. For example, if you double-click on the Password card “Amazon”, you will see the information that the user has stored about their account on Amazon as follows:
Info Cards can either be displayed in the right-hand pane, or if the information could be too big to fit, it can be displayed in a separate window (if you look at a Note info card, you will see that it is displayed in a separate window). The decision about where to display the information is left to the developer of the plug-in module that handles that category of Info Card.
If you right-click on a card listed in the tree, a popup menu is displayed that allows you to Display, Edit or Delete the card. If you select Edit, a modal dialog box is displayed that enables you to edit the data associated with that card. For example, if you select Edit on the password card shown above, you would see the following dialog box displayed:
If you right-click on a category in the tree, you can add a new card of that category. Or, if there are currently no cards stored of the type you want, you can select New Card from the Card menu and a dialog box will be displayed listing all of the categories supported, along with a description, which you can choose from. This is seen below:
Tasks
Read the following sections carefully. Although it may seem daunting at first, if you read through everything very carefully and approach this assignment methodically, you will find that there is not a huge amount of work needed. This assignment is intended to assess your understanding of the core concepts covered in this module, not to make you write a lot of code.
A lot of the application has already been written. The main user interface code exists (and is supplied to you) as well as the code that loads and saves Info Cards.
Although the example shown above shows Credit Card as one of the categories supported, this info card type has not yet been implemented. Only Password and Note are currently implemented. For this assignment you are to:
1. Write the plug-in module that will handle the Credit Card info card type.
2. Add an additional info card type of your choice to this plug-in module. For example, you could choose from frequent flyer numbers, bank account details, passport details or any other type of information you can imagine storing.
3. Add an additional card type to the system, this card must be a photo ID card which contains an image. Images may be stored and retrieved by file path. or by conversion to string data. Multiple file types may be supported.
The full specification of the interfaces you need to use and other information that will be helpful to you can be found in the appendix
Appendix
The Project Structure
A complete Visual Studio 2019 solution has been provided for you to work with in the zip file that accompanies this specification. You should unzip this, making sure you maintain the folder structure. Each plug-in module is a separate project that is compiled to form a dynamic-link library (DLL). These are searched for at run-time and loaded dynamically by the main application. The Visual Studio solution includes the following projects:
Assignment This is the main application. All of the source code for this is provided for you to look at. You should not change any of the source code in this project.
AssignmentInterfaces This contains the definitions of the interfaces you will need (IInfoCard and IInfoCardFactory) as well as other definitions used in the application. You must not add these to the InfoCards2 project – that project is already setup to refer to the AssignmentInterfaces project.
InfoCards2
This project is the one you must use to work on the assignment. The assignment properties and references are setup correctly to refer to the other projects in the solution where needed and to copy the built files into the correct place. You should add the classes you write for the assignment to this project. Do NOT add any files to any other project in this solution.
InfoCards
This is the class that loads and saves Info Cards. You might find this useful to look at since it will use methods that you write to perform this task.
(InfoCards1 was used to build the plug-in module that handles the Note and Password info cards. The source code for this is not available to you. However, the built version of this project (Infocards1.dll) has been placed in the Assignment folder and will automatically be copied to the correct place when you build the solution. Do not delete this file or change its properties.)
What You Need to Write
You will need to create the following classes in the InfoCards2 project:
• One class that implements the IInfoCardFactory interface
• Three classes that implement the IInfoCard interface. One of these classes will handle the Credit Card info card, another class will handle the additional info card you decide to implement. The third will handle the photo ID.
• For each info card, you will need two Windows Forms classes – one to display the details of the info card and the other to edit the info card.
The Interfaces
These interfaces are already defined in the AssignmentInterfaces project, so you should not add them to the InfoCards2 project. The interfaces are as follows:
IInfoCardFactory:
public interface IInfoCardFactory
{
IInfoCard CreateNewInfoCard(string category); IInfoCard CreateInfoCard(string initialDetails); string[] CategoriesSupported { get; } string GetDescription(string category);
}
The following describes what each of the methods and properties need to do:
CreateNewInfoCard
This method is called when the user wants to create a new Info card of the specified category. It returns a reference to an object that implements IInfoCard. For example, to create a new Password Info Card, the method is called with the category set to “Password”
CreateInfoCard
This is called when the file that stores the Info Card data is loaded into memory. The parameter passed to this method is a string that uses the following format:
Category|Rest of details of card
The method should create a new card of the specified category, using the data in the string that follows the category name and | character to initialise the card. A reference to the new info card object should be returned. For examples of the string passed to this method, see the description of the GetDataAsString method in the IInfoCard interface.
CategoriesSupported
Returns a string array containing the categories supported by this class. For example, if the class supports the categories “Credit Card” and “Account”, it should return a string array containing the strings “Credit Card” and “Account”.
GetDescription
Returns a string containing a description for the specified category. The description is used in the New Card dialog box.
IInfoCard:
public interface IInfoCard
{ string Name { get; set; } string Category { get; } string GetDataAsString(); void DisplayData(Panel displayPanel); void CloseDisplay();
bool EditData();
}
The following describes what each of the methods and properties need to do:
Name
Used to set and get the name of the Info Card. The name is used to identify the Info Card in the tree view
Category
The category of this info card. This should match one of the category values referenced in the factory class. This is used to determine where the card is to be positioned in the tree view
GetDataAsString
Returns the data stored in the info card in a form that can be written to a file. The format used is:
Category|Name|<other properties separated by |>
For example, for a password info card, the string returned might be:
Password|Amazon|www.amazon.com|joebloggs|mypassword
Note that this string is the string passed to the CreateInfoCard method in the class that implements IInfoCardFactory when the data is loaded from the file again. Apart from the category and the first “|” character, the rest of this information is only used inside the class that handles the info card
DisplayData
This method displays a windows form that displays the data in the info card.
The parameter passed to DisplayData is a reference to the panel to the right of the tree in the main application. If the data in the info card is small enough to fit inside this panel, the form can be displayed on that panel. This is not a requirement, but extra credit will be given if you can figure out how to do this. The form must not be closed by this method. It should only be closed by the CloseDisplay method.
CloseDisplay
This method should close the form displayed by the DisplayData method.
EditData This method displays a modal dialog box that allows the user to edit the data in the info card. Ideally, it should ensure that all fields in the info card contain data (i.e. there are no blank fields). If there are blanks, it is up to you to ensure that your class handles this sensibly when the data is retrieved using GetDataAsString and when a new info card is created.
EditData returns a bool that must be set to true if the data in the
info card has been changed, false if the data has not been changed.
Suggestions and Hints
The following are some suggestions and hints that you might find useful:
1. Do not try to implement all the info cards at once. Do the Credit Card info card first and only once you have that working correctly should you attempt the other cards.
2. Do not try to write all of the code at once. Break the development into stages and think carefully about what needs to be implemented at each stage so that it can be tested before proceeding to the next stage. For example, you do not need to have all of the methods in the class that implements IInfoCard written before you can test whether the plug-in module can be loaded by the main application.
3. Study the code in the main application to see how the IInfoCardFactory and IInfoCard methods and properties are used. You can debug the application to see how the methods in the classes are used (although you cannot see how they are implemented). There will be code in the main application that you are not familiar with, but don’t let that put you off. You can search through the code to see where the methods are called from.
4. If you are not sure what the credit card info cards forms should look like and what data should be stored, here are some suggestions (you are free to add additional information if you wish). Also feel free to use other controls if you feel they are more appropriate.