日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 新建double对象_java-如何在BlueJ“创建对象”对话框中输入...

發布時間:2025/3/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 新建double对象_java-如何在BlueJ“创建对象”对话框中输入... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我不嘗試將日期格式設置為YYYY-MM-DD或dd / MM / YYYY.我在問LocalDate的字面格式.

我剛剛開始學習Java,并且正在使用稱為BlueJ的IDE.我想創建一個測試方法.

屏幕截圖將顯示我正在嘗試做的

現在,從構造函數開始,我們知道它需要一個int,LocalDate和一個double.我在網上搜索后發現

07001

java.time.LocalDate: A LocalDate instance holds a date without a time

zone, in ISO-86011 calendar system. LocalDate has the default format

‘YYYY-MM-DD’ as in ‘2016-12-12’.

所以我將一個普通數字放在10001作為testID,并將double變成50.5

我也知道要為它注冊一個字符串(如果需要),我需要將其包含在“字符串”中

但是我嘗試了各種各樣的方式輸入日期,但我會遇到一個錯誤

2018-05-30,30-05-2018,30 / 05/2018將給我

Error: incompatible types: Int cannot be converted to java.time.LocalDate

另一方面,“ 30/05/2018”會給我

Error: Incompatible types: java.lang.String cannot be converted to java.time.LocalDate

如果我嘗試30.05.2018它會說

Error: ';' expected

如果我嘗試’2018-05-30’會說

Error: unclosed character literal

我沒有辦法嘗試.因此,如果您能告訴我如何將其放入其中,那就太好了.

我只是真的需要知道BlueJ如何讓我輸入它.因為BlueJ的資源在線如此稀疏.

碼:

import java.time.LocalDate;

import java.util.ArrayList;

/**

* Write a description of class TestPaper here.

*

* @author (your name)

* @version (a version number or a date)

*/

public class TestPaper

{

// instance variables - replace the example below with your own

private int testID;

private LocalDate testDate;

private double testMarks;

private ArrayList MCQDetails;

/**

* Constructor for objects of class TestPaper

*/

public TestPaper(int testID, LocalDate testDate, double testMarks)

{

this.testID = testID;

this.testDate = testDate;

this.testMarks = testMarks;

MCQDetails = new ArrayList() ;

}

/**

* Accessor Method getTestID to get the testID

*

* @return int value of the choice ID

*/

public int getTestID(){

return testID;

}

/**

* Mutator Method to set the testID

*

* @param int format of the testID to set

*/

public void setTestID(int testID){

this.testID = testID;

}

/**

* Accessor Method getTestMarks to get the Test Marks

*

* @return double value of the test marks

*/

public double getTestMarks(){

return testMarks;

}

/**

* Mutator Method to set the testMarks

*

* @param String format of the choice Description to be set

*/

public void setTestMarks(double testMarks){

this.testMarks = testMarks;

}

/**

* Accessor Method getTestDate to get the testDate

*

* @return LocalDate value of the testDate

*/

public LocalDate getTestDate(){

return testDate;

}

/**

* Mutator Method to set the testDate

*

* @param LocalDate format of the testDate to set

*/

public void setTestDate(LocalDate testDate){

this.testDate = testDate;

}

/**

* Method addMCQ will allow users to add a MCQ Object to the list of MCQ

*

* @param addMCQ a MCQ Object

* @return boolean will return true if it is successfully added or false if not

*/

public boolean addMCQ(MCQ MCQName)

{

return MCQDetails.add(MCQName);

}

/**

* Method removeMCQ to remove an MCQ object from the Arraylist

*

* @param MCQName A parameter of type MCQ

*/

public void removeMCQ(MCQ MCQName)

{

MCQDetails.remove(MCQName);

}

/**

* Method listMCQ to return a list of MCQ arraylist

*

* @return The return value of MCQDetails (MCQ Arraylist)

*/

public ArrayList listMCQ()

{

return MCQDetails;

}

public MCQ findMCQ(int MCQID)

{

for(MCQ m : MCQDetails)

{

if(m.getQuestionID() == MCQID)

{

return m;

}

}

return null;

}

總結

以上是生活随笔為你收集整理的java 新建double对象_java-如何在BlueJ“创建对象”对话框中输入...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。