עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

לוח משחק קצר ב-JAVA - של 2 שחקנים וכלל ההזזה

Featured Replies

פורסם

היי, יש לי משחק בJAVA לבנות. יש לו 4 מחלקות קצרות וMAIN שמנהל אותו.

ההדפסה של החיילים עובדת לי....

יש בעיה בהחלפה בין 2 השחקנים/קבוצות (team) וקביעת אדום או כחול לכל אחד מהם.

איפה במחלקות לשים את הקבוצות בMain ששמו Game?? האם לשים לכל סוג של שחקן (חייל/דרקון את המשתנה team) מהם???? 

במתודה להזיז אותם קשה להבין איך ניתן לבצע את ההזזה ללא הגדרת הקבוצות 

מצרפת את כל המחלקות שעשיתי...
תודה לעוזרים (:::::

 

import java.util.Scanner;

public class Game {
	static Scanner s = new Scanner(System.in);
	static String[][] board;
	static gameOfThrone teamRed;
	static gameOfThrone teamBlue;

	public gameOfThrone getRed() {
		return teamRed;
	}

	public void setRed(gameOfThrone red) {
		Game.teamRed = red;
	}

	public gameOfThrone getBlue() {
		return teamBlue;
	}

	public void setBlue(gameOfThrone blue) {
		Game.teamBlue = blue;
	}
ציטוט

	public void addDragon(int x, int y, String team, boolean direction, String name) {
		Point position = new Point(x, y);
		Dragon dragon = new Dragon(name, team, position, direction);
		int size = board.length;
		// int nameOfDragon = Integer.parseInt(name);
		// int nameOfDragon = Dragon.numOfDragon;
		// if (team.equals("BLUE")){
		// dragons[size + nameOfDragon] = dragon;
		// } else {
		// dragons[nameOfDragon] = dragon;
		// }
		String nameOfDragon = name.substring(4).trim();
		int nameDragon = Integer.parseInt(nameOfDragon);
		// int nameOfSoldier = Soldier.numOfSolider;
		if (team.equals("BLUE")) {
			dragons[nameDragon] = dragon;
			// soldiers[nameOfSoldier] = soldier;
		} else {
			dragons[nameDragon] = dragon;
		}
		this.board[x][y] = dragons[nameDragon].getName();
	}

 

 

Sketch.png

gameOfThorne.zip

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.