4 Replies - 290 Views - Last Post: 06 March 2012 - 06:10 PM Rate Topic: -----

#1 RafasLad  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 06-March 12

Basic C# help, beginner

Posted 06 March 2012 - 03:11 PM

Hi all, hoping someone out there can help me with some C# coding, struggling at the moment, want to throw my laptop out the window on to the front yard.

Basically I am building a C# console application, at the moment I have a menu in place, this menu allows the user to choose between two car factories, one in Detroit and one in Seattle, once the user chooses a factory, another message is displayed saying how many workers work at that specific factory, for convenience sake I've said two workers work at both factories. From there, I need a submenu to open that presents the user with four options:

1. Locate A Specific Vehicle
2. Locate A Specific Worker
3. Create A New Rota
4. Exit Menu

Could any of you please advise me on how to do so, the code I have at the moment is:

public string GetMenu()
        {
return "Welcome To " + this.factoryName + ".\nWe have " + myWorkers.Count.ToString() + " workers.";
        }


How do I create a sub menu after this line of code which holds the relevant data?

This post has been edited by JackOfAllTrades: 06 March 2012 - 03:18 PM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Basic C# help, beginner

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 6438
  • View blog
  • Posts: 23,430
  • Joined: 12-June 08

Re: Basic C# help, beginner

Posted 06 March 2012 - 03:19 PM

Break it down logically. We know that most programs execute each line from the top to the bottom. That means you would have the "which factory" question up at the top.. and right below that your preferred method of user input/storage of said input... then there you would have it ask your sub menu. Since it looks like the user can hit multiple options in a given application run it would be best to put that sub menu (and the code it executes) in a while loop that checks if the user's input is not the exit command.

Not too bad, right?
Was This Post Helpful? 0
  • +
  • -

#3 RafasLad  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 06-March 12

Re: Basic C# help, beginner

Posted 06 March 2012 - 03:33 PM

View Postmodi123_1, on 06 March 2012 - 03:19 PM, said:

Break it down logically. We know that most programs execute each line from the top to the bottom. That means you would have the "which factory" question up at the top.. and right below that your preferred method of user input/storage of said input... then there you would have it ask your sub menu. Since it looks like the user can hit multiple options in a given application run it would be best to put that sub menu (and the code it executes) in a while loop that checks if the user's input is not the exit command.

Not too bad, right?


Doesn't sound too difficult but I'm just lost altogether with it, any chance you could give me a form of example coding or similar to try and implement, PLEASE :(
Was This Post Helpful? -1
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 6438
  • View blog
  • Posts: 23,430
  • Joined: 12-June 08

Re: Basic C# help, beginner

Posted 06 March 2012 - 03:37 PM

Sorry chief - any example would literally *BE* your assignment done for you.

Try it out. Write an output statement and see about getting a user input.
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is online

  • Closing in on 5,000
  • member icon

Reputation: 4926
  • View blog
  • Posts: 10,463
  • Joined: 02-June 10

Re: Basic C# help, beginner

Posted 06 March 2012 - 06:10 PM

This is the 'Help me with my homework' article you wanted.

Suggestion:
Don't replace lines of code that don't work. Instead comment them out and put your new attemps below that. This will keep you from re-trying the same ideas over and over. Also, when you come back to us saying "I've tried this 100 different ways and still can't get it", we can actually see what you tried. So often a failed attempt is very very close and just needs a little nudge in the right direction. So if we can say "See what you did in attempt 3... blah blah" it helps a lot

// Try #1 - May 1, 0900hrs
//    code
//    code  
//    code
// Try #2 - May 2, 1700hrs   Okay, plan B.  What if I do it *this* way
//    code
//    code  
//    code
// Try #14 - May 3, 0500hrs after 5 cans of RedBull.  Maybe I should get some sleep. I can't think of anything else but this last idea
    code
    code  
    code


If you are using Visual Studio you can select a block of lines and hit control+k control+c (Kode Comment) to comment it out. control+k control+u (Kode Uncomment) to uncomment a selected block.

These articles may also apply:
Stages of asking for homework help on a forum.
I don't want you to write my code, just give me ideas on how to solve my problem. - Read this article

"It doesn't work" isn't good enough - How you can help us, to help you
"It doesn't work" isn't good enough - How you can help us, to help you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1