Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I already have the code for the game in a file as MyGameOfLife.java. I need to c

ID: 3911499 • Letter: I

Question

I already have the code for the game in a file as MyGameOfLife.java. I need to create a graphic now for it. Below is what it needs to look like

Graphical Output Component The lor dis 19:ews or 19 cells The (ells sbdllaytt betdee, l piel tuck on ca?ofthe Rue sides Usea saple praplical sbage N represente live cells The dead cells saleta t'eapy Crete an apglicatoe hod n) This can be in the Can ofLdDannd cless n main, creete a Trne Yo can h)se tbe lecarion and tofe ofthe vinde. The sze will be set by calling pck This iswty the Ceme01iond needs ot set is preferred size Renenter o set the deun close opem on sehat he pon endwen the window is ctosed The anan for Nam Cenerense ?.ocal no mnA tough

Explanation / Answer



import java.awt.*;
import java.awt.event.*;

final class UI implements Constants, Strings, WindowListener  
{
  
private gamerl rule;
private scrloc scrloc;
private Frame parentFrame;
private Objects obj;
private Vars vars;

private PopupWindow error; /* For program exceptions -- shouldn't
happen.
*/
private boolean quit; // If the user simply gets out.
boolean userWantsToSeeInstructions;


UI(Objects obj) // the bigger UI
{
this.obj = obj;
this.vars = null;
this.parentFrame = obj.GetParentFrame();
this.scrloc = obj.Getscrloc();
rule = null;
quit = false; // we begin thinking the user wants to see how the game is played
userWantsToSeeInstructions = true;
  
if (parentFrame == null)
{
System.out.println("Parent frame null in UI?!?!");
// System.exit(0);
}

  
error = new PopupWindow(parentFrame, obj.Getscrloc(), ERROR_WINDOW_NAME);

}

// Overidden methods from WindowListener interface:
// Only < windowClosing > matters: user hit the "x" "close me" icon.
public void windowClosing(WindowEvent e)
{
quit = true; // when X button is pressed
System.exit(0);
}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}


/* ******************************************************************
Screen displays question to user
****************************************************************** */

protected final void AskIfUserWantsToSeeInstructionsOrQuit(Vars vars)
{
String errorString = ((parentFrame != null) && (vars != null)) ?
NULL_STRING : "parentFrame = " + parentFrame +
" vars = " + vars;
if (!errorString.equals(NULL_STRING))
{
System.out.println("UI : Do you wish to see instructions???" +
errorString);
quit = true;
return;
}
PopupWindow seeInstructions; // This will be our display window.
  
/* The first question is, "Do you wish to see the instructions?
(Yes) (No)." Assuming that the pop window program is already coded
*/
seeInstructions = new PopupWindow(parentFrame, scrloc,
QUESTION); // Window name

// Display the question:
String [] strArr = {YES, NO, QUIT}; // Used in next:

seeInstructions.ShowMessage(SEE_INSTRUCTIONS_STRING,
strArr); // Buttons


if ((seeInstructions.WhichButtonWasPressed()).equals(YES))
{
userWantsToSeeInstructions = true;
  
PopupWindow displayInformationScreen = new PopupWindow(parentFrame,
scrloc,
INSTRUCTIONS); // Window name.
String [] stringArr = {OK, START_PLAYING, QUIT};

// Show the user the first set of information:

displayInformationScreen.ShowMessage(INSTRUCTIONS_STRINGS,
stringArr); // Button.
if ((displayInformationScreen.WhichButtonWasPressed()).equals(QUIT))
{
quit = true;
}
else if ((displayInformationScreen.WhichButtonWasPressed()).equals(START_PLAYING))
{
userWantsToSeeInstructions = false;
}
}
else if ((seeInstructions.WhichButtonWasPressed()).equals(NO)) // Hit the "No" button.
{
userWantsToSeeInstructions = false;
}
else if ((seeInstructions.WhichButtonWasPressed()).equals(QUIT))
{
quit = true;
}   
}
public boolean Quit() // Do we simply get out?
{
return quit;
}
public boolean UserWantsToSeeInstructions()
{
return userWantsToSeeInstructions;// Tell the patron if the
} // user requested instructions.
  

/* ******************************************************************
Routine < ShowUserInterfaceInstructions() > follows. shows the user the
rest of the instructions,if he checks "Yes."
********************************************************************* */

protected final void ShowUserInterfaceInstructions(Vars vars)
{
PopupWindow displayInformationScreen = new PopupWindow(parentFrame,
scrloc,
INSTRUCTIONS);
String [] strArr = {OK, QUIT}; // Used in next:

// Show the user the second set of information:

displayInformationScreen.ShowMessage(BEFORE_GAME_STARTS_INSTRUCTIONS, // Info
strArr); // Button.
if ((displayInformationScreen.WhichButtonWasPressed()).equals(QUIT))
{
quit = true;
}
}

/* ******************************************************************
This starts the bigger UI
that helps to finds how the user wishes to play the game.
********************************************************************* */

protected final boolean GetGameParametersScreen(Vars vars)
{
/* We always ask the user basic questions: how many rows, columns,
play by mouse click or time delay ...

Notable the <gamerl > class (which see, below)
is a sizable part of this file. It sets up a UI.
  
Note: No-one uses the next class except us, and we instantiate it. It
needs a pointer to < vars >, which we immediately feed it.
*/
if (rule == null)
{
rule = newgamerl(HOW_GAME_IS_PLAYED,
true, // Modal.
parentFrame,
obj,
vars);
}
else
{
rule.setBoardParameters();
}
rule.addWindowListener(this);
rule.pack();
rule.setLocation(
scrloc.GetLocationOnScreen(rule));
// do
{
rule.setVisible(true);
}//while (!rule.Done());
return rule.playGame();
}
  
public String toString()
{
return "class UI";
}

}  

The above image uploaded is not very clear after making some assumptions I have given the following code,

gamerl - game rules java file

scrloc - positiong the thing on the screen java file, I also assume that the questions on user's choice (to view the instructions of the games )window is already coded by the stu