[java]代码库
package C;
import java.util.*;
public class myclass {
public static void main(String[] args){
Patient april = new Patient();
april.setname("ZhangLi");
april.setsex('f');
april.setage(3);
april.setweight(154.72f);
april.setallergies(true);
System.out.println("Name: "+april.getname());
System.out.println("sex: "+april.getsex());
System.out.println("age: "+april.getage());
System.out.println("weight: "+april.getweight());
System.out.println("allergies: "+april.getallergies());
}
}
class Patient{
String name = new String();
char sex;
int age = 0;
float weight = 0;
boolean allergies;
public void setname(String a){
name = a;
}
public void setsex(char b){
sex = b;
}
public void setage(int c){
age = c;
}
public void setweight(float d){
weight = d;
}
public void setallergies(boolean e){
allergies = e;
}
public String getname(){
return name;
}
public char getsex(){
return sex;
}
public int getage(){
return age;
}
public float getweight(){
return weight;
}
public boolean getallergies(){
return allergies;
}
}