1 class person{ 2 String color; 3 public person(String color){ 4 this.color=color; 5 } 6 class heart{ 7 int suy; 8 int soy; 9 int zp; 10 public heart(int suy,int soy,int zp){ 11 this.soy=soy; 12 this.suy=suy; 13 this.zp=zp; 14 } 15 public void xt(){ 16 System.out.println(color+"的心在拼命的跳动!"); 17 } 18 19 } 20 public void HEART(){ 21 int a=1+(int)(Math.random()*523); 22 int b=1+(int)(Math.random()*323); 23 int c=1+(int)(Math.random()*241); 24 heart H=new heart(a,b,c); 25 System.out.println("心脏的帧频为:"+c); 26 System.out.println("舒张压为:"+b); 27 System.out.println("收缩压为:"+a); 28 H.xt(); 29 } 30 } 31 32 public class Demo3 { 33 34 public static void main(String[] args) { 35 int j=1+(int)(Math.random()*3); 36 switch(j){ 37 case 1: 38 person p1=new person("黄种人");p1.HEART();break; 39 case 2: 40 person p2=new person("黑种人");p2.HEART();break; 41 case 3: 42 person p3=new person("白种人");p3.HEART();break; 43 } 44 } 45 46 }
浙公网安备 33010602011771号