Это мой код. В моей основной функции я уже включил конструктор. У меня есть несколько конструктора в моем клиент классепроблема с конструктором
public class Client {
private String name = "", username = "", ClientID = "", password = "";
Client[] account = new Client[100];
public Client() {
}
public Client(String name, String username) {
// will have generated function for ClientID and also Password
account[clientCount] = new Client();
account[clientCount].setName(name);
account[clientCount].setUsername(username);
account[clientCount].setPassword(password);
account[clientCount].setClientID(CID);
}
public Client(String name, String username, String password, String ClientID) {
this.name = name;
this.username = username;
this.password = password;
this.ClientID = ClientID;
}
public static void main(String[] args) {
if (selection == 1) {
Client client = new Client(); // object created called "client"
name = JOptionPane.showInputDialog("Account Status: Admin\n" + "Please Enter Client Name: ");
username = JOptionPane.showInputDialog("Account Status: Admin\n" + "Please Enter Client Userame: ");
Client CLIENT = new Client(name, username);
JOptionPane.showMessageDialog(null,
CLIENT.account[Client.clientCount].getName() + "\n" + CLIENT.account[Client.clientCount].getUsername() + "\n"
+ CLIENT.account[Client.clientCount].getPassword() + "\n" + CLIENT.account[Client.clientCount].getClientID());
}
if (selection == 2) {
// at here, unable to access to CLIENT object, what can I do access
// CLIENT object to here. Or copy the same object into the other new
// object
for (int i = 0; i <= Client.clientCount; i++) {
System.out.println(CLIENT.account[i].getName());
}
}
}
}
И эта проблема ...? – Keppil
Я не могу получить доступ к объекту CLIENT за пределами «if (selection == 1)» – JaxLee
Давай, ребята, wtf? Повторите это слово и, пожалуйста, отформатируйте ответ. Sheesh. – Shiki