Modify the Guessing game from chapters 6-7 to play with

 Modify the Guessing game from chapters 6-7 to play with 2 players instead of 1 player by showing input and stats for player 1 and player 2.
– To end the game: You can ask for number of games to be played at the beginning of the game or you can ask the user whether to continue after each game.
– Display number of guesses for each player in addition to average number of guesses for each play.
– Show which player wins the whole match based on who has the least average number of guesses after the total number of games selected is over.
– When each game is played, change the output to display that the last guess is correct. Example: Congratulations! XXX is correct!
– When the players reach the total number of games chosen, or when the player chooses not to continue, display either: “Match over! Player 1 wins!” , OR “Match over! Player 2 wins!” , OR “Match over! It’s a tie!” 

MODIFY THE PROGRAM BELOW WITH THE PROVIDED INSTRUSTION UP IN just BASICSOFTWARE

‘ *************************************************************************

‘ Script Name: GuessMyNumber.bas (The Guess My Number Game)

‘ Version:     1.0

‘ Author:      Jerry Lee Ford, Jr.

‘ Date:        March 1, 2007

‘ Description: This game is a Just BASIC number guessing game that

‘              challenges players to guess a number between 1 and 100 in

‘              as few guesses as possible.

‘ *************************************************************************

nomainwin   ‘Suppress the display of the default text window

‘Declare global variables used to keep track of game statistics

global secretNumber, avgNoGuesses, noOfGamesPlayed, guessCount, helpOpen$

‘Assign default values to global variables

secretNumber = 0    ‘Keeps track of the game’s randomly generated number

guessCount = 0      ‘Keeps track of the total number of guesses made

avgNoGuesses= 0     ‘Stores the calculated average number of moves per game

noOfGamesPlayed = 0 ‘Keeps track of the total number of games played

helpOpen$ = “False” ‘Keeps track of when the #help window is open

WindowWidth = 510   ‘Set the width of the window to 500 pixels

WindowHeight = 500  ‘Set the height of the window to 500 pixels

ForegroundColor$ = “Darkblue”  ‘Set the window font color to dark blue

‘Define the format of statictext controls displayed on the window

statictext #play.statictext1, “G U E S S   M Y   N U M B E R”, _

  30, 50, 440, 40

statictext #play.statictext2, “Copyright 2007”, 395, 90, 80, 20

statictext #play.statictext3, “Games Played:”, 40, 400, 80, 20

statictext #play.statictext4, “Avg. No. Guesses:”, 265, 400, 90, 20

statictext #play.statictext5, “Enter Your Guess:”, 200, 140, 100, 20

statictext #play.statictext6, “Hint:”, 42, 300, 30, 20

‘Add button controls to the window

button #play.button1 “Guess”, AnalyzeGuess, UL, 210, 225, 80, 30

button #play.button2 “Help”, DisplayHelp, UL, 400, 318, 70, 25

button #play.button3 “Start Game”, StartGame, UL, 400, 288, 70, 25

‘Add three textbox controls and place them inside the groupbox control

textbox #play.textbox1, 200, 160, 100, 50

textbox #play.textbox2, 130, 395, 90, 22

textbox #play.textbox3, 370, 395, 90, 22

textbox #play.textbox4, 40, 320, 340, 22

‘Open the window with no frame and a handle of #play

open “Guess My Number” for window_nf as #play

‘Set up the trapclose event for the window

print #play, “trapclose ClosePlay”

‘Display the appropriate variable values in the following textbox controls

print #play.textbox3, avgNoGuesses

print #play.textbox2, noOfGamesPlayed

‘Set the font type, size, and properties for each of the static controls

print #play.statictext1, “!font Arial 24 bold”

print #play.statictext2, “!font Arial 8”

print #play.statictext5, “!font Arial 8 bold”

print #play.statictext6, “!font Arial 8 bold”

print #play.textbox1, “!font Arial 24”;

print #play.button3, “!setfocus”;  ‘Set focus to the Start Game button

print #play.button1, “!disable”    ‘Disable the Guess button

print #play.textbox1, “!disable”   ‘Disable the input textbox

‘Pause the application to wait for the player’s instruction

wait

‘This subroutine analyzes player guesses and determines when the game

‘has been won

sub AnalyzeGuess handle$

  ‘Retrieve the player’s guess and assign it to a variable

  print #play.textbox1, “!contents? playerGuess”

  ‘Validate that an acceptable value has been entered

  if playerGuess < 1 or playerGuess > 100 then

    ‘Inform the user that an invalid guess has been made

    print #play.textbox4, “Your guess must be between 1 and 100. Try again.”

    print #play.textbox1, “”  ‘Clear out the input textbox

    print #play.textbox1, “!setfocus”;  ‘set focus to the input textbox

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

  ‘Determine if the player’s guess is too low

  if playerGuess < secretNumber then

    ‘Increment the variable that tracks the total number of guesses made

    guessCount = guessCount + 1

    ‘Inform the user that the guess was too low

    print #play.textbox4, “Your guess was too low. Try again.”

    print #play.textbox1, “”  ‘Clear out the input textbox

    print #play.textbox1, “!setfocus”;  ‘set focus to the input textbox

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

  ‘Determine if the player’s guess is too high

  if playerGuess > secretNumber then

    ‘Increment the variable that tracks the total number of guesses made

    guessCount = guessCount + 1

    ‘Inform the user that the guess was too high

    print #play.textbox4, “Your guess was too high. Try again.”

    print #play.textbox1, “”  ‘Clear out the input textbox

    print #play.textbox1, “!setfocus”;  ‘set focus to the input textbox

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

  ‘Determine if the player’s guess was correct

  if playerGuess = secretNumber then

    ‘Let the player know he has won the game

    notice “Guess My Number” + chr$(13) + “Game over! You win!”

    ‘Increment the variable that tracks the total number of guesses made

    guessCount = guessCount + 1

   ‘Increment the variable that tracks the total number of games played

    noOfGamesPlayed = noOfGamesPlayed + 1

    ‘Calculate the average number of guesses per game

    avgNoGuesses = guessCount / noOfGamesPlayed

    ‘Display the appropriate variable values in the following textbox

    ‘controls

    print #play.textbox3, avgNoGuesses

    print #play.textbox2, noOfGamesPlayed

    print #play.textbox1, “”           ‘Clear out the input textbox

    print #play.button3, “!enable”     ‘Enable the Start Game button

    print #play.button3, “!setfocus”;  ‘Set focus to the Start Game button

    print #play.textbox1, “!disable”   ‘Disable the input textbox

    print #play.button1, “!disable”    ‘Disable the Guess button

    print #play.textbox4, “”           ‘Clear out the Hint textbox control

    exit sub  ‘Exit the subroutine without processing any remaining

              ‘subroutine statements

  end if

end sub

‘This subroutine is called when the player clicks on the Start Game button

sub StartGame handle$

  ‘Generate a new random number for the game

  secretNumber = int(rnd(1)*100) + 1

  print #play.button1, “!enable”      ‘Enable the Guess button

  print #play.textbox1, “!enable”     ‘Enable the input textbox

  print #play.button3, “!disable”     ‘Disable the Start Game button

  print #play.textbox1, “!setfocus”;  ‘Set focus to the input textbox

end sub

‘This subroutine is called when the player clicks on the Help button

sub DisplayHelp handle$

  helpOpen$ = “True”  ‘Identify the #help window as being open

  WindowWidth = 400   ‘Set the width of the window to 500 pixels

  WindowHeight = 400  ‘Set the height of the window to 500 pixels

  ‘Use variables to store text strings displayed in the window

  HelpHeader$ = “Game Instructions”

  helpText1$ = “The object of this game is to guess a randomly generated” _

    + ” number in the range of 1 to 100 in as few guesses as possible. ” _

    + “To make a guess, type in a number and click on the Guess button. ” _

    + “A hint will be provided after each move to assist you in making ” _

    + “your next guess. Once you have correctly guessed the game’s secret” _

    + ” number, a popup message will be displayed.”

  helpText2$ = “At the end of each round of play, game statistics are ” _

    + “displayed at the bottom of the game window as an indication of ” _

    + “your progress.”

  ‘Define the format of statictext controls displayed on the window

  statictext #help.helptext1, HelpHeader$, 30, 40, 140, 20

  statictext #help.helptext2, helpText1$, 30, 70, 330, 80

  statictext #help.helptext3, helpText2$, 30, 160, 330, 50

  ‘Add button controls to the window

  button #help.button “Close”, CloseHelpWindow, UL, 280, 310, 80, 30

  ‘Open the window with no frame and a handle of #play

  open “Guess My Number Help” for window_nf as #help

  ‘Set the font type, size, and properties for specified statictext control

  print #help.helptext1, “!font Arial 12 bold”

end sub

‘This subroutine is called when the player closes the #help window

sub CloseHelpWindow handle$

  helpOpen$ = “False”  ‘Identify the #hlp window as being closed

  close #help  ‘Close the #help window

end sub

‘This subroutine is called when the player closes the #play window

‘and is responsible for ending the game

sub ClosePlay handle$

  ‘Get confirmation before terminating program execution

  confirm “Are you sure you want to quit?”; answer$

  if answer$ = “yes” then  ‘The player clicked on Yes

    close #play  ‘Close the #play window

    ‘See if the #help window is open and close it if it is

    if  helpOpen$ = “True” then

      call CloseHelpWindow “X”  ‘Close the #help window

    end if

    end  ‘Terminate the game

  end if

end sub

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Research can take many forms. The two primary types of

Research can take many forms. The two primary types of research conducted in the School of Business doctoral programs at Liberty University are Academic Research or Applied Research. After reviewing the Reading and Study material for this module, conducting your own outside research, and considering the two different types of

Read the following article and answer the questions. (250 words)

    Read the following article and answer the questions. (250 words) https://www.healthline.com/health-news/people-more-stressed-today-than-1990s (Links to an external site.) Do you      think life is more stressful today than 30 years ago? Than      one hundred years ago? Why or why not? What      factors are responsible for the increase in perceived stress among      Americans?

Hamlet by William Shakespeare – Premium Paper Help

Premium Paper Help is a professional writing service that provides original papers. Our products include academic papers of varying complexity and other personalized services, along with research materials for assistance purposes only. All the materials from our website should be used with proper references.

Research Assignment -Part Three The final part of this assignment

Research Assignment -Part Three  The final part of this assignment will be to complete your research paper. Be sure to read the guidelines for the assignment before submission.  Research Paper Guidelines  (Note: Submitting a paper previously submitted for a grade is plagiarism, you will receive a 0) The selected topic

Unit 5 DB: Different Data StructuresIn addition to arrays, data

  Unit 5 DB: Different Data StructuresIn addition to arrays, data can be stored in indexed files and linked lists.a) In your initial post discuss the differences between multi-dimensional arrays, indexed files, and linked lists. What are the advantages and disadvantages of each? b) In your replies to your classmates discuss

pls watch the YouTube video and pls make sure include

pls watch the YouTube video and pls make sure include it on the work Start by completing your weekly assigned readings for this module (See “Reading for M11 discussion” file). For your initial reaction post, focus on how the papers use statistics. What are they trying to demonstrate and how? Are

Problems related to Price setting, Chapter 18 is attached. Here

Problems related to Price setting, Chapter 18  is attached.  Here is the guidance for preparation before solving the problems in the attached.  1.  Review and study Chapter 18 text. especially the topics on Cost based pricing and Break-even analysis 2. Watch the Video ppt recording for chapter 18 under Course

5.1 I need someone to help me In thinking about

5.1 I need someone to help me In thinking about the readings and videos presented in the unit, why do you think Latinos/Hispanics became and still remain targets of racists 5.2  I need someone Explain, in detail, using two sociological theories listed below, the crimmigration system at our southern border

The question 2 Answered Points out of 2.00 Not flagged

The question  2 Answered Points out of 2.00 Not flagged Flag question Question text The patient in Question #1 has been receiving palliative care for 6 months and has had improvement in some of his symptoms, but with worsening dementia, he gets up one night to use the bathroom and

The annual performance review is the most commonly recognized control

The annual performance review is the most commonly recognized control management tool. It is also the most feared by employees. You are the Branch Manager for a regional bank, and it is the dreaded annual performance review/evaluation/appraisal time. You have recognized that mostly employees dislike annual reviews and that they

1. What is the fundamental difference between a licensing agreement

   1. What is the fundamental difference between a licensing agreement and a joint venture as related to the Disney theme parks? 2. Why did the Walt Disney Company opt for a licensing agreement for Tokyo 
Disneyland? Please read the attached file . all answers are in there. 0% plagiarism

FIELD NOTES FROM SWEDEN, Part I: Unemployment, Alcoholism, and the

   FIELD NOTES FROM SWEDEN, Part I: Unemployment, Alcoholism, and the Swedish Black Market Imagine retiring at a young age as a “registered disabled” person. The reason? Alcoholism. The Swedish solution is for the state to pay you money to stay home and remain drunk. Treatment is optional. Interpretation of

Unit 5, Modules 17-20 focus on various qualities of leadership,

Unit 5, Modules 17-20 focus on various qualities of leadership, including how to listen, how to work in groups, how to conduct meetings, and how to present orally. For this final blog of the course, you will create a Professional Leadership Statement based on your experience as well as your

What are the differences between leaders and managers? What characteristics

What are the differences between leaders and managers? What characteristics are similar and what are different? Provide a total of three examples. First, of someone who has great managerial skills. Second, another individual with great leadership skills. Third, another person with poor managerial skills. These can be made up individuals