91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-03
  • 語言: Java
  • 標簽:

資源簡介

實驗1 類的定義、對象數組的使用 1. 定義一個學生類(Student), 屬性有 1)非靜態屬性String studentNumber 2)非靜態屬性String studentName 3)非靜態屬性int markForMaths 4)非靜態屬性int markForEnglish 5)非靜態屬性int markForScience 方法有: 1)構造方法Student(String number, String name) 2)構造方法Student() 3)String getNumber() 4)String getName() 5)void enterMarks(int markForMaths, int markForEnglish, int markForScience) 6)int getMathsMark() 7)int getEnglishMark() 8)int getScienceMark() 9)double calculateAverage() 10)String toString() 返回學生信息,包括學號、姓名、數學成績、英語成績、科學成績、平均成績。 注意:為了保證calculateAverage返回double類型,需要把三個分數的和除以3.0,而不是3. 另外,分數的初始值是什么?如果每個分數初始值為0,會造成混淆,分數為0表示還沒有輸入分數,還是分數確實為0?有更好的初始值嗎? 編寫Student類,并且編寫一個StudentTest類,對Student類進行測試。 StudentTest類運行效果如下: 請輸入學生學號:2011211301 請輸入學生姓名:王曉 請輸入學生三門課成績(數學,英語,科學):88,79,90 學生信息如下: 學號:2011211301 姓名:王曉 數學成績:88 英語成績:79 科學成績:90 平均成績:85.66666666666667 2.定義一個StudentList類用來存儲Student對象 屬性有 1)Student[] list; //list存儲學生對象 2)int total; //學生總人數 方法有: 1)StudentList(int length) //length是數組長度 2)boolean add(Student stu) //增加stu到數組中,成功,返回true,否則false 3)boolean remove(int no) //刪除第no個數組元素,刪除成功,返回true,否則false 4)boolean remove(Student number) //刪除學號為number的學生,刪除成功,返回true,否則false 5)boolean isEmpty() //判斷數組是否為空,若是,返回true,否則false 6)Student getItem(int no) //返回第no個學生 7)Student getItem(Student number) //返回學號為number的學生,若該生不存在,返回null。 8) int getTotal() 返回學生總人數 編寫StudentList類,并且編寫一個StudentListTest類,對StudentList類進行測試。 StudentListTest類運行效果: 菜單如下,請輸入 1~8代表您要執行的操作: 1. 增加1個學生 2. 根據學號刪除學生 3. 根據位置刪除學生 4. 判斷是否為空 5.根據位置返回學生 6.根據學號返回學生 7. 輸出全部學生信息 8.退出程序 請輸入您的操作:1 請輸入學生信息: 學號:2011211301 姓名:王曉 數學成績:88 英語成績:79 科學成績:90 ---目前有1個學生,信息為---: 學號:2011211301 姓名:王曉 數學成績:88 英語成績:79 科學成績:90 平均成績:85.66666666666667 請輸入您的操作:1 學號:2011211311 姓名:李輝 數學成績:80 英語成績:79 科學成績:93 ---目前有2個學生,信息為---: 學號:2011211301 姓名:王曉 數學成績:88 英語成績:79 科學成績:90 平均成績:85.66666666666667 姓名:李輝 數學成績:80 英語成績:79 科學成績:93 平均成績:84.0 請輸入您的操作:5 請輸入學生位置:10 對不起,沒有對應的學生 請輸入您的操作:5 請輸入學生位置:2 學生信息如下: 姓名:李輝 數學成績:80 英語成績:79 科學成績:93 平均成績:84.0 請輸入您的操作:3 請輸入要刪除第幾個學生:2 刪除成功 ---目前有1個學生,信息為:

資源截圖

代碼片段和文件信息

package?liujiajia;

public?class?_2014211512_劉佳佳_1_Student?{

private?String?studentNumber;
private?String?studentName;
private?int?markForMath;
private?int?markForEnglish;
private?int?markForScience;

public?_2014211512_劉佳佳_1_Student(String?numberString?name)
????{
????
???? this.studentNumber=number;
???? this.studentName=name;
????}

public?_2014211512_劉佳佳_1_Student()
{
this.studentName=null;
this.studentNumber=null;
}

public?String?getNumber()
{
return?studentNumber;
}

public?String?getName()
{
return?studentName;
}

public?int?getMathsMark()
{
return?markForMath;
}

public?int?getEnglishMark()
{
return?markForEnglish;
}

public?int?getScienceMark()
{
return?markForScience;
}

public?void?enterMarks(int?markForMathint?markForEnglishint?markForScience)
{
this.markForMath=markForMath;
this.markForEnglish=markForEnglish;
this.markForScience=markForScience;
}

public?double?calculateAverage()
{

return?(markForMath+markForEnglish+markForScience)/3.0;
}

public?String?toString()

{

return?“學生信息如下:\n?學號:“?+?studentNumber?+?“\n姓名:“?+?studentName?+?“\n?數學成績:“?+?markForMath
????????????+?“\n英語成績:“?+?markForEnglish?+?“\n科學成績:“?+?markForScience?+?“\n平均成績:“?+?calculateAverage()
????????????+?““;
}




}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????1418??2016-10-27?21:56??homework1\_2014211512_劉佳佳_1_Student.java

?????文件???????2042??2016-10-27?21:56??homework1\_2014211512_劉佳佳_1_StudentList.java

?????文件???????3383??2016-10-27?21:56??homework1\_2014211512_劉佳佳_1_StudentListTest.java

?????文件???????1031??2016-10-27?21:56??homework1\_2014211512_劉佳佳_1_StudentTest.java

?????目錄??????????0??2016-10-28?21:24??homework1

-----------?---------??----------?-----??----

?????????????????7874????????????????????5


評論

共有 條評論