I am working on an application in C# and I am having some extreme difficulty solving this design issue.
Basically the application allows users to create cook books. A user can click "new book" and the application will create a book with a given name. Now the user is allowed to add "recipes" to that book. The user can save the book at any time. They can load this book on other computers with the application. Only one book can be open at a time in the application. So if they user wants to create a new book or open a different book, the application will need to close the current book and then open the next book.
My question is, what would be the best way to solve this problem?
- How would I check if a book is open?
- How would I have the application create the new book?
- How would I have the application "close and forget" the book that was closed, so that the only open book is the new one?
What I was thinking is that I would have a CookBook class and a Recipe class. The CookBook class would hold the information pertaining to the new book that was created and it would hold a list of all the recipes in that CookBook. I am just having a hard time figuring out the best way to give the user the ability to create a new CookBook and close the current cook book so the user can create a new one.
The CookBook class will have a function that wil write the contents of the CookBook and the recipes of the CookBook to a file. There will also be a function in CookBook that will populate the application's user interface based on the contents of a CookBook that is loaded/opened by the user.