package mypack;
public class FanDemo {
public static void main(String args[]){
Fan a=new Fan();
System.out.println("风速:"+a.speed);
System.out.println("开关:"+a.on);
System.out.println("风扇半径:"+a.radius);
a.setSpeed();
a.setOn();
a.getSpeed();
a.getOn();
a.getRadius();
}
}
class Fan {
private int speed;
private boolean on;
private int radius;
public Fan(int speed, boolean on, int radius) {
this.speed = speed;
this.on = on;
this.radius = radius;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public boolean isOn() {
return on;
}
public void setOn(boolean on) {
this.on = on;
}
public int getRadius() {
return radius;
}
public void setRadius(int radius) {
this.radius = radius;
}
}
//另段源代码
package mypack1
class Box
{
double leight;
double wight;
double height;
public Box(Double l,Double w,Double h)
{
this.leight=l;
this.wight=w;
this.height=h;
}
public volume()
{
volume=height*wight*height;
return volume;
}
}
public class BoxDemo
{
public static void main(String[] args)
{
Box s=new Box(2,3,5);
v=s.volume();
System.out.println("立方体的体积为:"+v);
}
}