locked
Is this the correct use of console arguments or is there a better way RRS feed

  • Question

  • Helllo,

    I have this assignment :

    Create a system where you can add and remove libraries for a specific town, add, remove or edit books. 

    where the cities are folders and the stores are json files.

    We did not learn databases so far.

    Now I thinking of using console arguments to solve this in a nice way.

    So far I did this :

     private static void DisplayHelpText()
            {
                Console.WriteLine("usage: -f inputFileName -c cityName -bs bookstore -book bookName [shown/add/remove/edit]");
                Console.WriteLine("options:");
                Console.WriteLine("-f required The Json file to read the data from");
                Console.WriteLine("-c required the city where the bookstore is located");
                Console.WriteLine("--shown  Shows all the books from a bookstore in a city");
                Console.WriteLine("-- add  add a book to bookstore in a city");
                Console.WriteLine("-- remove) remove a book from a bookstore in a city");
                Console.WriteLine("-- edit  -- [name, author, avaibility] newValue edit a book property from a bookstore in a city");
                Console.WriteLine("-- avaiblity  [taken/avaible/reserved");
            }

    is this a good way or is there a better way I can make this work ?

    Friday, June 12, 2020 10:02 AM

All replies

  • That is pretty much the best way for an assignment. If it was not an assignment then the following would be best.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, June 12, 2020 10:26 AM
  • I think command line arguments would work if that is actually the requirement of the lab but I suspect it isn't. There are several problems with using the command line arguments. The biggest problem is that you only get to do one thing per run. So for example if you want to add a book then you'd have to run the app to add the book. Then run the app again to show the books. Run the app yet again to edit a book. etc. This doesn't make any sense and as an instructor I would not give you full credit for that. You should be able to run the app once and add/edit/view/delete as many times as you want without rerunning the app. Command line arguments won't work for this.

    Command line arguments is not how you will solve this lab. You need to build a simple menu system that allows the user to select from a list of options (add, edit, etc). When your app runs you display the menu. As the user selects options you will response to those requests using functions (most likely). In some cases a menu selection will trigger other prompts (e.g. confirmation of delete, collection of book data, etc). 

    You should probably talk with your instructor to determine whether they want to run your app once or multiple times to accomplish each task.


    Michael Taylor http://www.michaeltaylorp3.net

    • Proposed as answer by Naomi N Friday, June 12, 2020 1:30 PM
    Friday, June 12, 2020 1:26 PM
  • I agree with Michael (you may try the option Karen suggested). Just to point out that I also noticed typos in the word availability - you may want to correct that as well before hanging over the assignment.

    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    Friday, June 12, 2020 1:33 PM