I am trying to create a new object and initialize it with the parameters which are passed by the following command :
java -jar JAR-FILE.jar store Information.dat ClientName "Address" City Country HomePhone OfficePhone CellPhone
where ClientName
is the name of the client , "Address"
contains the client's address and etc. The client can have a HomePhone
or a OfficePhone
or a Cellphone
or all of these and even more phone numbers.
here is the class which I tried to initialize it with parameters :
private static void SaveClient(String[] args) throws Exception
{
Client SaveClient = new Client(...);
....
out.writeObject(SaveClient);
out.close();
}
here is the Client
constructor :
public class Client{
private String ClientName;
private Address address;
private List<String> PhoneNumbers;
public Client() {
this.PhoneNumbers = new ArrayList<String>();
}
public Client(String ClientName, Address address) {
this();
this.name = ClientName;
this.address = address;
}
public void AddPhoneNumber(String number) {
this.PhoneNumbers.add(number);
}
....
}
but I don't know how to initialize it with the passing parameters. We can assume the information is valid, also I don't want to make any changes to the "Client" constructor just modifying the SaveClient