I need to create a phoneBook. Thanks to a form, I can retrieve a person's data. I need to use objects for that purpose. I created a phoneBook() object with the help of a method that enables to add a person in the phoneBook.
I decided (it wasn't asked for though) to divide the "person" concept in 2, which results in a "Person" object and an "AddressPerson" object (a same person can have two houses: "My tailor is rich!" :-))
Is it a good way to declare the Person object?
Can we create a Person object without address and add it later on like I did with the "Person2" object?
If someone could help me, I'd be very obliged. Thank you very much in advance!"
function phoneBook(){
this.Liste = new Array();
}
phoneBook.prototype.Add = function(){
Liste.push(new Person(aLastName,aFirstName,aAddress));
}
function Person(aLastName,aFirstName,aAdd){
this.LastName = aLastName;
this.FirstName = aFirstName;
this.Address =
new AddressPerson(aAdd.Street,aAdd.CP,aAdd.Town,aAdd.NumTel,aAdd.Email);
}
function Person2(aLastName,aFirstName){
this.LastName = aLastName;
this.FirstName = aFirstName;
this.Address = 'unknow';
}
function AddressPerson(aStreet,aCP,aTown,aNumTel,aEmail){
this.Street = aStreet;
this.CP = aCP;
this.Town = aTown;
this.NumTel = aNumTel;
this.Email= aEmail;
}