資源簡介
ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8

代碼片段和文件信息
import?java.util.*;
/**
?*?This?class?contains?methods?to?process?array?lists?of?{@link?Student}
?*?objects.
?*
?*?@author??autor?name
?*?@version??1.0.0
?*?@see??Student
?*?@see??ArrayList
?*/
public?class??StudentArrayList??{
/**
?*?Returns?an?array?list?with?three?elements.
?*
?*?@param?first??a?Student
?object.
?*?@param?second??a?Student
?object.
?*?@param?third??a?Student
?object.
?*?@return?an?array?list?with?the?objects?first
?*???????????second
?and?third
?*/
public?static?ArrayList?makeArrayList(
Student??first
Student??second
Student??third)??{
????ArrayList?student=new?ArrayList();
????student.add(first);
????????????student.add(second);
????????????student.add(third);
????return?student;
}
/**
?*?Returns?an?array?list?with?the?same?elements?of?the?specified?array
?*?arranged?in?the?same?order.
?*
?*?@param?array??an?array?with?Student
?objects?.
?*?@return?an?array?list?with?the?same?elements?of?the?specified?array
?*?????????arranged?in?the?same?order
?*/
public?static?ArrayList?makeArrayListFromArray(Student[]?array)?{
????????ArrayList?student=new?ArrayList();
????????for(Student?std:array){
???????? student.add(std);
???????? }
???return?student;
}
/**
?*?Returns?true
?if?the?specified?array?list?contains?a
?*?student?whose?id?matches?the?specified?ID.
?*
?*?@param?arrayList??an?array?list?of?Student
?objects.
?*?@param?id??a?student?ID.
?*?@return??true
?if?the?specified?array?list?contains?a
?*??????????student?whose?ID?matches?the?specified?ID;
?*??????????false
?otherwise.
?*/
public?static?boolean?hasStudent(
ArrayList??arrayList
int??id)??{
???????
???????
???????for(Student?std:arrayList){
??????? ??if(std.getId()==id)
??????? ????return?true;
??????? }
??????? return?false;
}
/**
?*?Returns?the?number?of?students?in?the?specified?array?list?whose
?*?grade?is?greater?than?or?equal?to?the?specified?grade.
?*
?*?@param?arrayList??an?array?list?of?Student
?objects.
?*?@param?grade??a?grade.
?*?@return??the?number?of?students?in?the?specified?array?list?whose
?*??????????grade?is?greater?than?or?equal?to?the?specified?grade.
?*/
public?static?int?countGradeGreaterOrEqual(
ArrayList?arrayList
int?grade)??{
???????int?count=0;
???????for(Student?std:arrayList){
??????? if(std.getGrade()>=grade)
??????? ???++count;
??????? }
????????return?count;
}
/**
?*?Returns?the?smallest?grade?of?the?students?in?the?specified?array?list.
?*?
?*?This?method?assumes?that?the?array?list?is?not?empty.
?*
?*?@param?arrayList??an?array?list?of?Student
?objects.
?*?@return??the?smallest?grade?of?the?students?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2010-11-30?22:26??practical?quiz?8\
?????目錄???????????0??2010-11-30?22:26??practical?quiz?8\student-files\
?????文件????????1088??2006-01-11?06:07??practical?quiz?8\student-files\Student.class
?????文件????????2512??2005-12-03?00:19??practical?quiz?8\student-files\Student.java
?????文件????????1382??2006-01-11?06:07??practical?quiz?8\student-files\StudentArrayList.class
?????文件????????4392??2005-12-01?01:44??practical?quiz?8\student-files\StudentArrayList.java
?????文件????????6463??2006-01-11?06:07??practical?quiz?8\student-files\TestStudentArrayList.class
?????文件????????9785??2005-12-01?01:44??practical?quiz?8\student-files\TestStudentArrayList.java
?????文件????????5373??2010-11-30?22:24??practical?quiz?8\StudentArrayList.java
- 上一篇:基于proteus的8086和8253
- 下一篇:基于單片機的FSK調制器設計
評論
共有 條評論