Answered step by step
Verified Expert Solution
Link Copied!

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 (3) 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 (0,0) needs to be approximately
located at the center. Draw the x- and y-axes as a guide.
B. Provide the UML class of the whole application.
Note: Creating a thicker line needs to utilize Graphics2D API instead of Graphics.
Hangman.java
import acm.program.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Hangman extends ConsoleProgram {
// dimensions of window
private static final int APPLICATION_WIDTH =1080;
private static final int APPLICATION_HEIGHT =640;
public void run(){
// TODO: write this method
// Example:
displayHangman(0);
}
// TODO: comment this method
private void intro(){
// TODO: write this method
}
// TODO: comment this method
private int playOneGame(String secretWord){
// TODO: write this method
return 0;
}
// TODO: comment this method
private String createHint(String secretWord, String guessedLetters){
// TODO: write this method
return "";
}
// TODO: comment this method
private char readGuess(String guessedLetters){
// TODO: write this method
return '?';
}
// TODO: comment this method
private void displayHangman(int guessCount){
File file = new File("assets/display"+ guessCount +".txt");
Scanner scanner;
try {
scanner = new Scanner(file);
int line_counter =1;
while (scanner.hasNextLine()){
String line = scanner.nextLine();
println(line);
canvas.printText(line);
// canvas.printDisplay(data, line_counter);
line_counter++;
}
scanner.close();
} catch (FileNotFoundException e){
e.printStackTrace();
}
}
// TODO: comment this method
private void stats(int gamesCount, int gamesWon, int best){
// TODO: write this method
}
// TODO: comment this method
private String getRandomWord(String filename){
// TODO: write this method
return "";
}
public void init(){
canvas = new HangmanCanvas();
setSize(APPLICATION_WIDTH, APPLICATION_HEIGHT);
add(canvas);
canvas.reset(); // sample canvas method call
println("Hello LBYCPEI!");
println("This is the next line!");
}
/* Solves NoClassDefFoundError */
public static void main(String[] args){
new Hangman().start(args);
}
// private HangmanCanvas canvas;
private HangmanCanvas canvas;
}
HangmanCanvas.java
/*
* File: HangmanCanvas.java
*---------------------
* This class holds the graphics elements to the Hangman game.
* Author: Cobalt - M.Cabatuan
* Date modified: 06/11/2019
*/
import acm.graphics.GCanvas;
import acm.graphics.GLabel;
public class HangmanCanvas extends GCanvas {
private static final int TEXT_HEIGHT =20; // you can modify this to suit your ascii art
private static final int TEXT_X_OFFSET =12; // 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 GLabel("Hello LBYCPEI!");
textX = TEXT_X_OFFSET;
textY = TEXT_HEIGHT;
add(testMessage, textX , textY);
GLabel nextMessage = new GLabel("This is the next line!");
textY += TEXT_HEIGHT;
add(nextMessage, textX , textY );
printText("Custom println()");
}
public void printText(String text){
GLabel line = new GLabel(text);
line.setFont("Monospaced-plain-12");
textY += TEXT_HEIGHT;
add(line, textX , textY );
}
/* Write your methods here */
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions

Question

Refer to Exercise

Answered: 1 week ago

Question

Define offboarding. Why is it important?

Answered: 1 week ago