学生类
package com.hp.jwq.com.hp.jwq;
public class Student {
private String name;
private double money;
private static double clazzMoney;
public void flowerMoney(double money){
System.out.println(this.name+"原有钱"+this.money);
this.money-=money;
System.out.println("花了"+money+"元,还剩"+this.money);
}
public void flowerClazzMoney(double money){
System.out.println("班费原有钱"+clazzMoney);
this.money-=money;
System.out.println("花了"+money+"元,还剩"+clazzMoney);
}
public Student() {
}
public Student(String name, double money) {
this.name = name;
this.money = money;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getMoney() {
return money;
}
public void setMoney(double money) {
this.money = money;
}
public static double getClazzMoney() {
return clazzMoney;
}
public static void setClazzMoney(double clazzMoney) {
Student.clazzMoney = clazzMoney;
}
}
测试类
package com.hp.jwq.com.hp.jwq; public class Test { public static void main(String[] args) { Student s1 = new Student("xx",10000); Student s2 = new Student("ss",200); s1.flowerMoney(1000); s2.flowerMoney(200); s1.flowerClazzMoney(10000); s2.flowerClazzMoney(1000); } }