⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 card.java

📁 玩儿地雷游戏 猜字母 连续点击的两个字母相同则翻开 不同则全都盖上重新来 直到把所有的字母打开
💻 JAVA
字号:
/**
 * The Card class represents a single card in the grid.
 * 
 * @author ZHU JING
 * StudentID:0631118
 * Project: 3
 * Date:2009/03/31
 */
public class Card {

    /* TO DO!
     * Add private fields here. What fields does Card need?
     * Well, each Card has its own character value ('Z', 'Q', etc) and 
     * each Card is either facing up or facing down.
     *   
     * So probably you need two private fields...
     */
    public static final char BACK_OF_CARD = '-';
    private char letter;
    //@SuppressWarnings("unused")
	private boolean unfold;

    /**
     * Creates a new Card with a specified value. Card will be facing down.
     * 
     * @param value the character value for this Card
     */
    public Card(char value) {
        /* TO DO!
         * Give a specified value to the card;
         */
    	letter = value;
    }


    /**
     * Sets this card to facing up.
     */
    public void setFaceUp() {
        /* TO DO!
         * The card will be set to face up if its state unfolder is true;
         */
		 unfold=true;
    }


    /**
     * Sets this card to facing down.
     */
    public void setFaceDown() {
        /* TO DO!
         * The card will be set to face down if its state unfolder is false;
         */
		 unfold=false;
    }


    /**
     * Tests whether this card is facing up.
     * @return true if this card is facing up, false otherwise.
     */
    public boolean isFacingUp() {
        /* TO DO!
         * Make the card's state unfolder true to stay facing up
         */
		return (unfold==true);
    }


    /**
     * Print this card. 
     * If the card is facing up, prints the value. 
     * If the card is facing down, prints BACK_OF_CARD. 
     */
    public void print() {
        /* TO DO!
         * If this card's state unfolder is true,print the value.Otherwise,print '-';
         */
		 if(unfold==true)
		{
             System.out.print(letter);
	    }
		 else
		{
			 System.out.print(BACK_OF_CARD);
		}
    }


    /**
     * Compares this Card to the specified card. 
     * 
     * @param c The card to compare this Card against. 
     * @return true if the cards have the same value, false otherwise.
     */
    public boolean matches(Card c) {
        /* TO DO!
         * Test wheather c.letter and letter are the same.If it's the same,return true;
		 * c.letter is the card against;
         */
		 //letter==c.letter;
		 return (letter==c.letter);
    }


	/*public void setLetter(char letter) {
		this.letter = letter;
	}


	public char getLetter() {
		return letter;
	}*/
}

⌨️ 快捷键说明

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