作业
2016-03-08 07:55
239 查看
---恢复内容开始---
View Code
---恢复内容结束---
package juxing; public class Pig { // 4,写一个传奇游戏中的猪类,类中有属性:颜色(color)、 // 重量(weight)、攻击力(attack)、准确度(accuracy)。 // 再写一个测试类,生成一个猪的对象,将此猪的颜色值为“白色(white)”, // 重量为5,攻击力为50点,准确度为0.8。 // 要求输出此猪的信息格式为:一只白色的猪,重量5,攻击为50点血,准确度为0.8, // 我好怕怕呀 // // // 可以加上静态,重载 String color; double weight; int attack; double accuracy; public String getColor() { return color; } public void setColor(String color) { this.color = color; } public double getWeight() { return weight; } public void setWeight(double weight) { this.weight = weight; } public int getAttack() { return attack; } public void setAttack(int attack) { this.attack = attack; } public double getAccuracy() { return accuracy; } public void setAccuracy(double accuracy) { this.accuracy = accuracy; } public Pig(String color, double weight, int attack, double accuracy) { super(); this.color = color; this.weight = weight; this.attack = attack; this.accuracy = accuracy; } public static void main(String[] args) { Pig zhu=new Pig("白色",5,50,0.8); System.out.println("一只"+zhu.getColor()+"的猪,重量"+zhu.getWeight()+",攻击为"+zhu.getAttack()+"点血,准确度为"+zhu.accuracy+",我好怕怕呀"); } }
View Code
---恢复内容结束---
相关文章推荐
- oracle GROUPING函数
- Linux用户和用户组基本概念
- andriod VideoView
- rcnn学习笔记:Rich feature hierarchies for accurate object detection and semantic segmentation
- HDU 2105 The Center of Gravity (水题)
- huffman树_优先权队列
- js和jquery获取父级元素、子级元素、兄弟元素的方法{转}
- pat1057 stack
- pat1057 stack
- 十进制转化为八进制
- 单例模式(Singleton)
- Bravo!Java学习笔记(3)---多线程
- 原码、补码、运算(加减、异或)实例
- 树莓派3或开启物联网革命的大门
- 数据挖掘学习路线
- 下面哪些机制可以用于进程间通信?
- 构造函数中,哪些成员变量一定要通过初始化列表来初始化
- 操作对象-小测试(完善) 获取运算后的值
- js用currentStyle和getComputedStyle获取css样式(非行间)
- Linux学习笔记:常用命令整理