Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the same point class: A . Design and write an ACM Graphics program utilizing a similar interface to the Hangman but focuses on plotting
Using the same point class:
A Design and write an ACM Graphics program utilizing a similar interface to the Hangman but focuses on
plotting at least three mathematical objects, namely point using GOval line Gline and circle
GOval Make sure to utilize the Point blueprint class utilized above. For Example:
Note: You decide the scaling or the max values but the graph origin needs to be approximately
located at the center. Draw the and axes as a guide.
B Provide the UML class of the whole application.
Note: Creating a thicker line needs to utilize GraphicsD API instead of Graphics.
Hangman.java
import acm.program.;
import java.ioFile;
import java.ioFileNotFoundException;
import java.util.Scanner;
public class Hangman extends ConsoleProgram
dimensions of window
private static final int APPLICATIONWIDTH ;
private static final int APPLICATIONHEIGHT ;
public void run
TODO: write this method
Example:
displayHangman;
TODO: comment this method
private void intro
TODO: write this method
TODO: comment this method
private int playOneGameString secretWord
TODO: write this method
return ;
TODO: comment this method
private String createHintString secretWord String guessedLetters
TODO: write this method
return ;
TODO: comment this method
private char readGuessString guessedLetters
TODO: write this method
return ;
TODO: comment this method
private void displayHangmanint guessCount
File file new Fileassetsdisplay guessCount txt;
Scanner scanner;
try
scanner new Scannerfile;
int linecounter ;
while scannerhasNextLine
String line scanner.nextLine;
printlnline;
canvas.printTextline;
canvas.printDisplaydata linecounter;
linecounter;
scanner.close;
catch FileNotFoundException e
eprintStackTrace;
TODO: comment this method
private void statsint gamesCount, int gamesWon, int best
TODO: write this method
TODO: comment this method
private String getRandomWordString filename
TODO: write this method
return ;
public void init
canvas new HangmanCanvas;
setSizeAPPLICATIONWIDTH, APPLICATIONHEIGHT;
addcanvas;
canvas.reset; sample canvas method call
printlnHello LBYCPEI!";
printlnThis is the next line!";
Solves NoClassDefFoundError
public static void mainString args
new Hangmanstartargs;
private HangmanCanvas canvas;
private HangmanCanvas canvas;
HangmanCanvas.java
File: HangmanCanvas.java
This class holds the graphics elements to the Hangman game.
Author: Cobalt MCabatuan
Date modified:
import acm.graphics.GCanvas;
import acm.graphics.GLabel;
public class HangmanCanvas extends GCanvas
private static final int TEXTHEIGHT ; you can modify this to suit your ascii art
private static final int TEXTXOFFSET ; you can modify this to suit your ascii art
private int textX;
private int textY;
Resets the display so that only the hangman scaffold appears
public void reset
Sample graphics object
GLabel testMessage new GLabelHello LBYCPEI!";
textX TEXTXOFFSET;
textY TEXTHEIGHT;
addtestMessage textX textY;
GLabel nextMessage new GLabelThis is the next line!";
textY TEXTHEIGHT;
addnextMessage textX textY ;
printTextCustom println;
public void printTextString text
GLabel line new GLabeltext;
line.setFontMonospacedplain;
textY TEXTHEIGHT;
addline textX textY ;
Write your methods here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started