新年到了,祝大家新年快乐,礼物就送SSD1的部分答案哦
2007-12-31 19:57
761 查看
把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
}
}
先来一篇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
}
}
相关文章推荐
- 给大家的新年礼物
- 祝大家新年快乐,新年吉祥!
- 献给大家的新年礼物,同时祝大家新年愉快 :)
- 献给大家的新年礼物--能够在我的机器理站住脚跟的一些软件(简介)
- 至此新年之际,代表大连.Net俱乐部祝愿大家新年快乐,万事如意
- 祝大家新年快乐,新年吉祥!
- 新年第一帖,祝大家新年快乐!
- 祝大家新年快乐,新年吉祥!
- Linus Torvalds给大家的新年礼物:Linux Kernel 4.15 RC6发布
- 祝大家新年快乐,新年吉祥!
- 新年了,祝大家新年快乐!
- 新年到了, 写了几个网页祝福大家新年快乐, 万事如意
- 【新年祝福】散去2009分,祝大家新年快乐,祝所有朋友新的一年里万事如意。
- Linus Torvalds给大家的新年礼物:Linux Kernel 4.15 RC6发布
- 《1024伐木累》-新年到了,祝大家新年快乐!
- 十个新年banner,祝大家新年快乐!
- 新年快到了,祝大家新年快乐!
- 开发者面试百问-测试部分答案
- 前端面试知识点锦集(HTML部分)——附答案
- 开发者面试百问-测试部分答案