新年到了,祝大家新年快乐,礼物就送SSD1的部分答案哦

把SSD1的答案贴上来(SSDx 的答案将会后续连载)作为给各位学弟学妹的新年礼物,新年快乐咯
先来一篇exercise4的答案
(声明:不许转载)

Catfish.java
/**
 *  Author:   
 *  Date:    2007/04/25
 *  Description: Practical Quiz 5
 *                
 */
public class Catfish {

    /**
     * Location of the catfish - which column.
     */
    private int column = 1;

    /**
     * Energy level of catfish
     */
    private int energyLevel = 10;

    /**
     * Image of the catfish - is really a filename.
     */
    private String imageFileName;

    /**
     * Location of catfish - the column
     *
     * @return - an integer representing the column location of catfish.
     */
    public int getColumn() {

        return column;   // return the column value
    }

    /**
     * Swim one cell to the right by incrementing the value stored in column by 1.
     */
    public void swimRight() {
   
        if (column + 1 <= 10) {
           
            column = column + 1;          // Increment the value stored in column attribute by 1 and
            energyLevel = energyLevel - 1;// decrement the value stored in energyLevel by 1 if the
                                          // new value of column is less than or equal to 10.        
        }

    }

    /**
     * get the image of catfish
     *
     * @return a String indicating the filename of catfish image
     */
    public String getImage() {

        if (energyLevel >= 5)
        {
            imageFileName = "/Catfish.gif";   // The iamge of a catfish that is not tired is "/CatFish.gif".    
        }
        else
        {
            imageFileName = "/Catfish-tired.gif"; // The image of a tired catfish (a catfish with energyLevel less than 5)
                                                  // is "/CatFish-tired.gif".
        }
        return imageFileName;     // return the image filename that represents the catfish
    }
     
   
   
   
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值