Browse Source

上传文件至 'W2周梓浩202506050319'

main
zhouzihao 4 weeks ago
parent
commit
5b204bbe43
  1. 33
      W2周梓浩202506050319/Main.java

33
W2周梓浩202506050319/Main.java

@ -0,0 +1,33 @@
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…
Cancel
Save