random - C# Dice game, turn this into a user typed input -


ive made dice "game" randomly chooses number , "rolls" see how many rolls takes same number. problem im having how can make pyöräytys typed in user.

using system; using system.collections.generic; using system.linq; using system.text;  namespace noppapeli {     class program     {         static void main(string[] args)         {             int pyöräytys;             int satunnainen;             int luku = 0;              random noppa = new random((int)datetime.now.ticks);              int.tryparse(console.readline(),out pyöräytys);             console.writeline("arvon numeron ja sitten koitan saada sen uudelleen");             console.writeline("haettava numero on: " + pyöräytys);             console.readline();                         {                 luku++;                 satunnainen = noppa.next(1, 7);                 console.writeline("numero on: " + satunnainen);                 if (satunnainen == pyöräytys)                 {                     satunnainen = pyöräytys;                 }             } while (pyöräytys != satunnainen);              console.writeline("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");             console.writeline("haettu numero: " + pyöräytys);             console.writeline("pyöräytetty numero: " + satunnainen);             console.write("kesti " + luku + " nopan pyöräytystä saada tulos!");             console.readline();         }     } } 

i tried changing pyöräytys = noppa.next(1,7); read key pressed couldnt find anything.

edit: solution whiletruesleep, updated in code above. thing, can input number on 6 goes on infinite loop. how make number must between 1-6.

int.tryparse(console.readline(), out pyöräytys); 

edit: replace line against pyöräytys = noppa.next(1, 7); user can enter value in console. if input not valid pyöräytys stay default value (0).


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -