مدرسه مایس
جمعه, ۲ آبان ۱۳۹۹، ۰۲:۴۰ ب.ظ
import java.util.*;
public class Course {
private String name;
private List<Student> people=new ArrayList<Student>();
public boolean register(Student s) {
if(people.size()<10)
{
people.add(s);
return true;
}
return false;
}
public int getNumOfStudents() {
return people.size();
}
public Student[] getStudents() {
Student[] ans = new Student[ people.size() ];
// Student[] ans=new Student[cnt];
// for(int i=0;i<cnt;i++)ans[i]=people[i];
// return ans;
return people.toArray(ans);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
}
۹۹/۰۸/۰۲