1 changed files with 0 additions and 33 deletions
@ -1,33 +0,0 @@ |
|||||
class Student{ |
|
||||
String studentId; |
|
||||
String name; |
|
||||
double score; |
|
||||
|
|
||||
//define a study approach |
|
||||
void study() { |
|
||||
System.out.println(studentId+" "+name+"正在学习,上一次的成绩是"+score); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
public class Main { |
|
||||
public static void main (String[] args) { |
|
||||
|
|
||||
//setting up the first object |
|
||||
Student s1=new Student(); |
|
||||
s1.studentId="001"; |
|
||||
s1.name="George"; |
|
||||
s1.score=90; |
|
||||
|
|
||||
//setting up the second object |
|
||||
Student s2=new Student(); |
|
||||
s2.studentId="002"; |
|
||||
s2.name="Roya"; |
|
||||
s2.score=95; |
|
||||
|
|
||||
//using the approach study() |
|
||||
s1.study(); |
|
||||
s2.study(); |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue