Thread: Attempting to create a skeleton C code on a slot machine

  1. #1
    Registered User
    Join Date
    Mar 2021
    Posts
    4

    Attempting to create a skeleton C code on a slot machine

    Hi I知 new to C and I知 having problems with creating a Finite State Machine skeleton code.

    I知 meant to create a skeleton code for a slot machine. The functionality of the slot machine is that it has 3 numbers which change in random fashion. The machine has 2 buttons (Start and Stop). The slot machine starts changing all 3 numbers after the Start button is pressed. Then pressing the Stop button repeatedly will stop one number at a time (there are 3 numbers). A win is indicated on the display if all 3 numbers are the same. The game can then be restarted again by pressing the Start button.

    Can anyone please draw up the skeleton code for me and show me how you did it- so I can do it for myself from here on in. Much appreciated!

  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,249
    I've no idea what is actually available on that machine so a simple loop is all I'm going with, start button should initiate the app, stop button should provide any kind of input that does not match start, although convention would likely be -1 or something to indicate end of file. I didn't fill in the details, go research that yourself.
    Code:
    int slots[3] = {0};
    int main()
    {
      while ( poll(1, ...) )
      {
        slots[0] = rand_r(slots[2]);
        slots[1] = rand_r(slots[0]);
        slots[2] = rand_r(slots[1]);
      }
      return 0;
    }

  3. #3
    Registered User
    Join Date
    Mar 2021
    Posts
    4
    Quote Originally Posted by NewguytoC View Post
    Hi I知 new to C and I知 having problems with creating a Finite State Machine skeleton code.

    I知 meant to create a skeleton code for a slot machine. The functionality of the slot machine is that it has 3 numbers which change in random fashion. The machine has 2 buttons (Start and Stop). The slot machine starts changing all 3 numbers after the Start button is pressed. Then pressing the Stop button repeatedly will stop one number at a time (there are 3 numbers). A win is indicated on the display if all 3 numbers are the same. The game can then be restarted again by pressing the Start button.

    Can anyone please draw up the skeleton code for me and show me how you did it- so I can do it for myself from here on in. Much appreciated!
    Hi can anyone please help? It would be much appreciated if anyone could provide a skeleton code? Thanks

  4. #4
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    804
    Quote Originally Posted by NewguytoC View Post
    Hi can anyone please help? It would be much appreciated if anyone could provide a skeleton code? Thanks
    If this is an assignment, we are not here to do your homework for you, either "skeleton code" or actual C code!

    You need to attempt to do at least a first cut of the program, then we can comment on your code.

    You also need to read the "Forum Rules FAQ" first before posting.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 10-19-2018, 02:27 PM
  2. Please! Need help with slot machine code
    By petertrieu in forum C Programming
    Replies: 3
    Last Post: 11-24-2015, 06:46 PM
  3. How can I get this slot machine code to run?
    By Nick Petraglia in forum C Programming
    Replies: 15
    Last Post: 11-21-2015, 10:27 AM
  4. Need help with slot machine code
    By p0l4r21 in forum C Programming
    Replies: 4
    Last Post: 10-31-2015, 01:55 AM
  5. IDEA: A Slot Machine (aka a fruit machine)
    By ygfperson in forum Contests Board
    Replies: 0
    Last Post: 08-12-2002, 11:13 PM

Tags for this Thread