Guest User

Untitled

a guest
Feb 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. /* Name: Antar Vasi
  2. * Class: ECCS 164 SEC 02
  3. * Assignment: Lab 6
  4. * Purpose: To create a children's math game with a
  5. * random number generator and a score count.
  6. * Date Assigned:
  7. * Date Due: 10/23/06
  8. */
  9.  
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13.  
  14. namespace ConsoleApplication2
  15. {
  16. class childrensGame
  17. {
  18. static void Main()
  19. {
  20. Random random1 = new Random();
  21. DisplayGame();
  22.  
  23. }
  24.  
  25. // This method will display the game to the user directly.
  26. //////////////////NON-WORKING/////////////////////////
  27.  
  28. public static void DisplayGame
  29. (int op1, string operation, int op2, int totalScore)
  30. {
  31.  
  32. Console.WriteLine("Welcome to the game.");
  33.  
  34. op1 = generateNumber(//what goes here?);
  35. op2 = generateNumber(//what goes here?);
  36. operation = generateOperation(//what goes here?);
  37.  
  38. Console.WriteLine("What is {0} {1} {2}", op1, operation, op2);
  39.  
  40. }
  41.  
  42.  
  43. // This method generates a random number from 1 to 10
  44. // and will return this random number to the Main function.
  45. //////////////////////WORKS///////////////////////
  46.  
  47. public static int generateNumber(Random random2)
  48. {
  49. int rndNumber;
  50.  
  51. rndNumber = random2.Next(0, 10);
  52.  
  53. return rndNumber;
  54. }
  55.  
  56. //This method generates a random operation.
  57. /////////////////NON-WORKING////////////////////
  58. public static string generateOperation(Random random3)
  59. {
  60. int rndNumber2 = random3.Next(0, 3);
  61.  
  62.  
  63. if (rndNumber2 == 0) // Addition operation
  64. {
  65. Console.Write("+");
  66. }
  67. else if (rndNumber2 == 1) // Subtraction operation
  68. {
  69. Console.Write("-");
  70. }
  71. else // Multiplication operation
  72. {
  73. Console.Write("*");
  74. }
  75.  
  76. }
  77. }
  78. }
Add Comment
Please, Sign In to add comment