question 1
JustBasic allows you to use file from your computer to load into your program. Use some specific examples to explain the advantages of importing files from your computer into your program.
question 2
Modify the Tic-tac-toe program Below
1. Modify the Tic-tac-toe program to add two little windows on each side of the "Start Game" button: On the left, first window will say "Player X Turn" only when Player X needs to play and second window will say "Wins" to keep count of payer X wins. On the right-hand side of the "Start Game" button, do the same for "Player O".
' *************************************************************************
'
' Script Name: TicTacToe.bas (The Tic Tac Toe Game)
' Version: 1.0
' Author: Jerry Lee Ford, Jr.
' Date: March 1, 2007
'
' Description: This game is a Just BASIC implementation of the classic
' children's Tic Tac Toe game. This game pits two players
' against one another to see who can line up three
' consecutive characters in a row.
'
' *************************************************************************
nomainwin 'Suppress the display of the default text window
'Assign default values to global variables
global currentPlayer$, noMoves
global a1$, a2$, a3$, b1$, b2$, b3$, c1$, c2$, c3$
currentPlayer$ = "X" 'Player X always starts off each game
call ManageGamePlay 'Call the subroutine responsible for managing game play
wait 'Pause the application and wait for the player's instruction
'This subroutine displays the game board and controls interaction with the
'player
sub ManageGamePlay
WindowWidth = 400 'Set the width of the window to 500 pixels
WindowHeight = 500 'Set the height of the window to 500 pixels
loadbmp "_", "C:images_.bmp" 'Load the specified bitmap
'file into memory
loadbmp "O", "C:imageso.bmp" 'Load the specified bitmap
'file into memory
loadbmp "X", "C:imagesx.bmp" 'Load the specified bitmap
'file into memory
'Define the format of statictext controls displayed on the window
statictext #play.statictext1, "T I C T A C T O E", 45, 20, 440, 30
statictext #play.statictext2, "Copyright 2007", 265, 55, 80, 20
'Add nine bmpbutton controls representing the game board to the window
'First column
bmpbutton #play.a1, "C:images_.bmp", ProcessMove, UL, 45, 90
bmpbutton #play.a2, "C:images_.bmp", ProcessMove, UL, 150, 90
bmpbutton #play.a3, "C:images_.bmp", ProcessMove, UL, 255, 90
'Second column
bmpbutton #play.b1, "C:images_.bmp", ProcessMove, UL, 45, 194
bmpbutton #play.b2, "C:images_.bmp", ProcessMove, UL, 150, 194
bmpbutton #play.b3, "C:images_.bmp", ProcessMove, UL, 255, 194
'Third column
bmpbutton #play.c1, "C:images_.bmp", ProcessMove, UL, 45, 298
bmpbutton #play.c2, "C:images_.bmp", ProcessMove, UL, 150, 298
bmpbutton #play.c3, "C:images_.bmp", ProcessMove, UL, 255, 298
'Add the game's button control to the window
button #play.button1 "Start New Game", ResetGameBoard, UL, _
147, 420, 100, 30
'Open the window with no frame and a handle of #play
open "Tic Tac Toe" for window_nf as #play
'Set up the trapclose event for the window
print #play, "trapclose ClosePlay"
'Set the font type, size and attributes
print #play.statictext1, "!font Arial 24 bold"
print #play.button1, "!setfocus"; 'Set focus to the button control
'Pause the application and wait for the player's instruction
wait
end sub
'This subroutine processes player moves, deciding when moves are
'valid and invalid and assigning game board squares accordingly
sub ProcessMove handle$
'Set up a select case code block to process player moves
select case handle$
case "#play.a1" 'The player selects the 1st square on the 1st row
if a1$ = "" then 'Let the player have the square if its available
a1$ = currentPlayer$ 'Assign the square to the current player
print #play.a1, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.a2" 'The player selects the 2nd square on the 1st row
if a2$ = "" then 'Let the player have the square if its available
a2$ = currentPlayer$ 'Assign the square to the current player
print #play.a2, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.a3" 'The player selects the 3rd square on the 1st row
if a3$ = "" then 'Let the player have the square if its available
a3$ = currentPlayer$ 'Assign the square to the current player
print #play.a3, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.b1" 'The player selects the 1st square on the 2nd row
if b1$ = "" then 'Let the player have the square if its available
b1$ = currentPlayer$ 'Assign the square to the current player
print #play.b1, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.b2" 'The player selects the 2nd square on the 2nd row
if b2$ = "" then 'Let the player have the square if its available
b2$ = currentPlayer$ 'Assign the square to the current player
print #play.b2, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.b3" 'The player selects the 3rd square on the 2nd row
if b3$ = "" then 'Let the player have the square if its available
b3$ = currentPlayer$ 'Assign the square to the current player
print #play.b3, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.c1" 'The player selects the 1st square on the 3rd row
if c1$ = "" then 'Let the player have the square if its available
c1$ = currentPlayer$ 'Assign the square to the current player
print #play.c1, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.c2" 'The player selects the 2nd square on the 3rd row
if c2$ = "" then 'Let the player have the square if its available
c2$ = currentPlayer$ 'Assign the square to the current player
print #play.c2, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
case "#play.c3" 'The player selects the 3rd square on the 3rd row
if c3$ = "" then 'Let the player have the square if its available
c3$ = currentPlayer$ 'Assign the square to the current player
print #play.c3, "bitmap " + currentPlayer$ 'Display bitmap image
else
notice "Sorry, but this square is already assigned. Try again!"
exit sub 'There is no need to keep going so exit the subroutine
end if
end select
noMoves = noMoves + 1 'Increment the variable representing the number of
'moves made so far in this game
'Call the subroutine responsible for determining when the game is over
call LookForEndOfGame
'Call the subroutine responsible for controlling whose turn it is
call SwitchPlayerTurn
end sub
'This subroutine is responsible for switching between Player X and
'Player O's turns
sub SwitchPlayerTurn
'If Player X just went then it is Player O's turn
if currentPlayer$ = "X" then
currentPlayer$ = "O" 'Make Player O the current player
exit sub 'There is no need to keep going so exit the subroutine
end if
'If Player O just went then it is Player X's turn
if currentPlayer$ = "O" then
currentPlayer$ = "X" 'Make Player X the current player
exit sub 'There is no need to keep going so exit the subroutine
end if
end sub
'This subroutine is called at the end of each player's turn and is
'responsible for determining if the game is over
sub LookForEndOfGame
'Look horizontally for a winner
'Check the first column
if (a1$ = currentPlayer$) and (a2$ = currentPlayer$) and _
(a3$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'Check the second column
if (b1$ = currentPlayer$) and (b2$ = currentPlayer$) and _
(b3$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'Check the third column
if (c1$ = currentPlayer$) and (c2$ = currentPlayer$) and _
(c3$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'Look vertically for a winner
'Check the first row
if (a1$ = currentPlayer$) and (b1$ = currentPlayer$) and _
(c1$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'Check the second row
if (a2$ = currentPlayer$) and (b2$ = currentPlayer$) and _
(c2$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'Check the third row
if (a3$ = currentPlayer$) and (b3$ = currentPlayer$) and _
(c3$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'Look diagonally for a winner
'Check from the top-left corner down to the lower-right corner
if (a1$ = currentPlayer$) and (b2$ = currentPlayer$) and _
(c3$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'Check from the top-right corner down to the lower-left corner
if (a3$ = currentPlayer$) and (b2$ = currentPlayer$) and _
(c1$ = currentPlayer$) then
notice "Player " + currentPlayer$ + " has won!"
exit sub 'There is no need to keep going so exit the subroutine
end if
'If neither player has won and all squares have been chosen the game
'ends in a tie
if noMoves = 9 then
notice "Tie. There was no winner this time!"
end if
end sub
'This subroutine resets the game board and global variables in order to
'ready the game for a new round of play
sub ResetGameBoard handle$
'Display a blank bitmap image in each game board square
print #play.a1, "bitmap _"
print #play.a2, "bitmap _"
print #play.a3, "bitmap _"
print #play.b1, "bitmap _"
print #play.b2, "bitmap _"
print #play.b3, "bitmap _"
print #play.c1, "bitmap _"
print #play.c2, "bitmap _"
print #play.c3, "bitmap _"
'Clear out any game board square assignments
a1$ = ""
a2$ = ""
a3$ = ""
b1$ = ""
b2$ = ""
b3$ = ""
c1$ = ""
c2$ = ""
c3$ = ""
noMoves = 0 'Reset the variable used to keep track of the total number
'of moves made per game to zero
currentPlayer$ = "X" 'Set Player X as the current player
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 quit?"; answer$
if answer$ = "yes" then 'The player clicked on Yes
close #play 'Close the #play window
end 'Terminate the game
end if
end sub
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
Ace Writing Center has stood as the world’s leading custom essay writing services providers. Once you enter all the details in the order form under the place order button, the rest is up to us.
Essays
At Ace Writing Center, Nowadays, students normally have extremely busy schedules. You will note that some of them have to take on some evening or weekend jobs in order to get some income that can help them to sustain in college or in the university. This can deny them a chance to write all the essays given. Others usually get bombarded with a lot of work by their lecturers. This can still delay such students from working on all their essays. However, some of them usually try to work on all these essays but end up delivering their work late. This can prevent them from graduating since most lecturers are strict on deadlines. If you want to write a business essay, the wise way is to hire an outstanding essay writing service like us, so that you can get the best results. If you are keen, you will note that many companies usually overcharge their customers. Some of them are there only to make money. And in reality, they really don’t care to build a long term commitment with students. You should not choose such companies. You should take your time and choose a reliable company to work with. Ace Writing Center is the ultimate solution for you. We have been offering our writing service for more than 7 years. This is a clear indication that you will get quality essay writing service. We have a wide range of writers who can work on any business essay that you might have. We believe in doing extensive research so that we can provide quality work to all our clients. .
Admissions
Admission and Business Papers
Have you ever had to write an admission essay for college? The majority of students face the same issues when applying to a university or college and many in such situations decide they need professional help to cope with this matter. They get in a situation when the deadline keeps coming closer but lack motivation to start because they are just not sure if their writing skills are strong enough. We have a solution for you! Ace Writing Center is the best admission essay writing service with a large professional team and years of experience in providing high-quality papers to students of all levels and faculties. The mission of our team is to help students make their dreams of entering a good college come true and that’s what we offer!.
Editing
Editing and Proofreading
Sometimes all the words for your paper just flow out of your mind and into your fingers. You type quickly at your keyboard and there they are, your beautiful words right there on the screen. But you have no idea how to polish it up. You may be wishing there was a paper writing service that offered this type of writing service. Look no more! Here at Ace Writing Center, we offer you an editing and proofreading option that you can't find anywhere else..
Coursework
College Essay Writing
In case you are familiar Ace Writing Center, you know the way to distinguish a better company from a cheap one exactly. First of all, poor service website does not have a sufficient support. We think support team is an essential part of success; it has to answer all clients’ questions and be a connecting link between clients and their writers. On our web-service you will get answers about anything you need and your writer will receive all your instructions, assignments and requirements exactly and swiftly. A writing service that we run has got a flexible pricing system that will save you from senseless wastes and many bonus systems that let you sparing money for something important for you.