Reference no: EM131472337
Part A -
Write a program to play the game of Nim with the computer. To play Nim, start with 15 tokens. Each player takes from one up to a maximum of three tokens at each turn, and the player taking the last token loses. Randomly choose whether the user or the computer moves first. At start up, display all the tokens. When it is user's turn, display a prompt message to ask the user to select his/her tokens. Let the user select a token with a mouse click, which should cause the token to be erased. When finished selecting tokens, the user should press the D key. Make sure the user never selecting more than three tokens. The computer should print a message stating how many tokens it chooses, and these tokens should be erased. When the game is over, display a message announcing the winner. User may press the N key to start a new Game.
You may implement an easy version. Instead of playing against the computer, two players play each other.
Help:
Using an array of bool type called cleared to hold 15 bool value and all initialized to false. Using a bool variable called turn. If turn is true means, it is first player's turn otherwise it is second player's turn. Every time there is a mouse click, locate the index where he/she clicked. If it is a painted square and the user has not clicked more than 3 times, set the cleared array at the index to true, call invalidate to repaint then the square will be cleared. Every time, a D key is pressed, check for winner. If there is one token left, whoever has the turn loses. If there is no token left, whoever has the turn wins. When the user pressed N key, reset all variables.
Part B -
Create a TipCalculator like
Amount
|
|
Tip (%)
|
|
Split
|
|
Total (per Person)
|
|
Left four are labels. The last one on the right is also a label. Other three are textboxes.
Initially set Tip as 15% while user can modify it.
Initally set Split as 1 while allow user to modify it.
You should catch click event in each one of them. Any time one of the boxes makes a change, adjust the total
For Example, it may look like
Amount
|
40
|
Tip (%)
|
15
|
Split
|
2
|
Total (per Person)
|
$23
|
Ephesians emphasizes god action in planning
: In addition to the church and love, Ephesians emphasizes God's action in planning, decreeing, and providing salvation.
|
Effects of public debt on income distribution
: What are some real or potential effects of public debt on income distribution, economic incentives, fiscal policy, and private investment?
|
Review the case study of jones
: Jones (appellee) signed a printed contract form agreeing to purchase a house from Long. Long also signed the form. At the time of signing, Jones also made.
|
How does the hundreds and thousands of immigrants
: How does the hundreds and thousands of immigrants, legal and illegal from around the world that come into the United States affect the country economically.
|
Write a program to play the game of nim with the computer
: Write a program to play the game of Nim with the computer. To play Nim, start with 15 tokens
|
Reflect on your practicum experiences
: Reflect on your Practicum Experiences.Analyze a problem, issue, or situation that you have observed during your Practicum Experience.
|
Can healy legally hold bratman liable for his oral promise
: Bratman, an attorney, had a client who was injured in an automobile accident and was being treated by Dr. Healy. Bratman orally promised to pay Healy.
|
Consumption function upward or downward
: What does the textbook say are the two factors that shift the consumption function upward or downward?
|
Examine the concept of the johari window
: Explain the importance of self-awareness in leadership development. Examine concept of Johari Window and apply this concept to your own leadership development.
|