In our previous blogs we have
discussed about our approach and logic of the code. You must be wondering what do
we see in the output window and what are the actual codes! Here you go, in this blog we will take a peek at the code and the output they result into.
When we
run our code, this is the first window that pops up. The User can choose the
number of players.
Java SWING has a function named
actionPerformed, we have used Button actionPerfmoded in our project
extensively. When the user clicks the onscreen button, the button fires action
event and executes the piece of code written in that function. Thus, further in
the blog, we’ve mentioned the actions and the functions.
When one clicks the Two Users
Button, a new window pops up and the following code is written in the function.
The function makes sure that it is executed when the button is clicked.
If the User clicks on the One
User button, again another window pops up which has the same design as the Two
Users mode but different logic as discussed previously. The function for the same
is given below.

There’s something very interesting
to note here! The functions to open the desired User window is the main
function from that file. This implies that there is NO main function present in
the User Mode files i.e. they cannot run on their own. When the button is
clicked we dispose the current window and the main of another file is called
and thus the window pops up.
The following is the window that
has the same design for both the modes One User mode as well as Two Users mode.

When we are in the One User mode, the code piece given below
runs the game.


When we get in Two Users mode, this piece of code comes in
action.

After a
particular game is won by the User or either of any Users, we have two options
either the user can refresh and start a new game or the User can choose the
number of users.
When Refresh button is clicked,
this function is executed which makes sure that the user can enjoy another
game.

When
user clicks on User Mode button, the following function gets executed, this is
the main function of the first file that we executed.
This was
all about what code we have written and what kind of Output is visible to the
User. I hope this blog gave you a clear idea about the flow of our game. In the
next and the last blog, we will try to put up some more additions(if any) to enhance
our code aesthetically and problems faced by us(obviously with their solutions
xD). Until then, HAPPY CODING!
This is very very helpful.
ReplyDeleteThank You!
DeleteGood👏
ReplyDeleteGreat work!!
ReplyDeleteThank you! Do try it yourself.
DeleteSeems very interesting !!
ReplyDeleteIt definitely is!
DeleteGreat job 👏🏼
ReplyDeleteWell done!!
ReplyDeleteThank You!
DeleteVery well written 👍
ReplyDeleteThank You! Give it a shot.
DeleteGreat work😘😘😘
ReplyDeleteThank You!!
DeleteGood information 👍
ReplyDeleteThank You!
DeleteGreat job!👍
ReplyDeleteIt is very informative. Good work.
ReplyDeleteThank You! Do visit other blogs as well.
DeleteGood work. Keep posting!
ReplyDeleteThank You! We will surely keep posting!
DeleteWell portrayed!
ReplyDeleteThank You!
DeleteVery Informative..
ReplyDeleteThank You!
Deletevery nice
ReplyDeleteGood work ��
ReplyDelete