hangmancanvas.java

来自「很有趣的著名游戏Hangman」· Java 代码 · 共 109 行

JAVA
109
字号
/* * File: HangmanCanvas.java * ------------------------ * This file keeps track of the Hangman display. */import acm.graphics.*;public class HangmanCanvas extends GCanvas {	private int count = 0;	public void drawHangman(){		if(count == 0) createRope();		if(count == 1) createHead();		if(count == 2) createUpperArm();		if(count == 3) createLowerArm();		if(count == 4) createHip();		if(count == 5) createLeg();		if(count == 6) createFoot();		count++;	}private void createFoot() {		// TODO Auto-generated method stub			}private void createLeg() {		// TODO Auto-generated method stub			}private void createHip() {		// TODO Auto-generated method stub			}private void createLowerArm() {		// TODO Auto-generated method stub			}private void createUpperArm() {		// TODO Auto-generated method stub			}private void createRope() {		// TODO Auto-generated method stub			}private void createHead() {		// TODO Auto-generated method stub			}/** Resets the display so that only the scaffold appears */	public void reset() {		this.removeAll();		createScaffold();		createBeam();		count = 0;	}private void createBeam() {	// TODO Auto-generated method stub	}private void createScaffold() {	// TODO Auto-generated method stub	}/** * Updates the word on the screen to correspond to the current * state of the game.  The argument string shows what letters have * been guessed so far; unguessed letters are indicated by hyphens. */	public void displayWord(String word) {		add(new GLabel(word),getWidth()/8, getHeight() * 3 / 4);	}/** * Updates the display to correspond to an incorrect guess by the * user.  Calling this method causes the next body part to appear * on the scaffold and adds the letter to the list of incorrect * guesses that appears at the bottom of the window. */	public void noteIncorrectGuess(char letter) {		/* You fill this in */	}/* Constants for the simple version of the picture (in pixels) */	private static final int SCAFFOLD_HEIGHT = 360;	private static final int BEAM_LENGTH = 144;	private static final int ROPE_LENGTH = 18;	private static final int HEAD_RADIUS = 36;	private static final int BODY_LENGTH = 144;	private static final int ARM_OFFSET_FROM_HEAD = 28;	private static final int UPPER_ARM_LENGTH = 72;	private static final int LOWER_ARM_LENGTH = 44;	private static final int HIP_WIDTH = 36;	private static final int LEG_LENGTH = 108;	private static final int FOOT_LENGTH = 28;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?