我有一個名爲客戶端的類,我將用來存儲客戶端註冊表信息,他們的名字和電子郵件,這將是他們的帳戶登錄信息的Java文件。我在這裏有點卡住了。實現一個帳戶類
這是一個有點什麼,我至今
public class ClientAccount {
private String name;
private String email;
/**This intializes an instance of ClientAccount
public ClientAccount(String name, String email) {
this.name = name;
this.email = email;
}
該代碼將返回一個字符串與客戶的姓名和電子郵件的類。
現在我需要一個從字符串創建客戶端和實例的方法。
/**
* Creates an instance of Client from a String.
*
* @param s a String
* @return an instance of Client
* @requires s is a string that contains the email address of the client
* and its name, separated by a comma (,). The string must contain exactly
* one comma.
* @ensures the returned value c is such that c.getEmail is equal to the
* email address specified in s and c.name is equal to the name specified
* in s.
*/
public static ClientAccount fromString(String s) {
}
s是包含客戶端 和它的名字的電子郵件地址,用逗號分隔的字符串。返回客戶端實例
public String toString() {
// TODO
return this.email+","+this.name;
}
問題是? – UnholySheep
「我有一個名爲Client的類的java文件」我看到一個名爲'ClientAccount'的類,而不是'Client'。我建議你學會對細節進行這樣的挑剔,因爲當你試圖編程時,電腦是無情的文字。 –
@ Code-Apprentice的確如此,因爲在我發佈問題之前,我改變了一些代碼。 – Exzlanttt