Object thinking
public class example{
public static void main(String[] args){
Random random=new Random();
float x=random.nextFloat();
int n=(int)(50*x+50);
switch(n/10){
case 9: System.out.println("A"+sign(n)+"You are great!"); break;
case 8: System.out.println("B"+sign(n)+"A nice work!"); break;
case 7: System.out.println("C"+sign(n)+"You can do better!"); break;
case 6: System.out.println("D"+sign(n)+"Congratulations!"); break;
default: System.out.println("Please work harder!");
}
}
public static String sign(int score){
if(n%10<2) return("-");
else if(n%10>7) return("+");
else return("");
}
}
Write the above,to say to me that please remember the orient object thinking in the heart.
Everything is a object,and object is everything.
The program passage above show that "sign(n)" is a class.And because lack the object thinking, I can't work out it at first.
Making progress is the main topic for ever!
public static void main(String[] args){
Random random=new Random();
float x=random.nextFloat();
int n=(int)(50*x+50);
switch(n/10){
case 9: System.out.println("A"+sign(n)+"You are great!"); break;
case 8: System.out.println("B"+sign(n)+"A nice work!"); break;
case 7: System.out.println("C"+sign(n)+"You can do better!"); break;
case 6: System.out.println("D"+sign(n)+"Congratulations!"); break;
default: System.out.println("Please work harder!");
}
}
public static String sign(int score){
if(n%10<2) return("-");
else if(n%10>7) return("+");
else return("");
}
}
Write the above,to say to me that please remember the orient object thinking in the heart.
Everything is a object,and object is everything.
The program passage above show that "sign(n)" is a class.And because lack the object thinking, I can't work out it at first.
Making progress is the main topic for ever!
0 Comments:
Post a Comment
<< Home