-
Notifications
You must be signed in to change notification settings - Fork 10
/
classes.js
68 lines (57 loc) · 1.89 KB
/
classes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var Contact = (function() {
"use strict";
function Contact(id, name, gender, company, email, phone, address) {
var argsArray = _.toArray(arguments);
if (argsArray.length != 7) {
throw {
name: "ArgumentsException",
message: "The arguments length is incorrect."
};
}
if (!_.isNumber(id) || !_.isString(name) || !_.isString(gender) || !_.isString(company) || !_.isString(email) || !_.isString(phone) || !_.isString(address)) {
throw {
name: "ArgumentsException",
message: "One of the arguments does not have the expected type."
};
}
this.id = id;
this.name = name;
this.gender = gender;
this.company = company;
this.email = email;
this.phone = phone;
this.address = address;
this.type = "contact";
}
Contact.prototype.getContactNameIdAndType = function() {
return this.name + " (" + this.id + " - " + this.type + ")";
};
return Contact;
}());
var Client = (function() {
"use strict";
function Client(id, name, gender, company, email, phone, address, registered, preferredBike, bikePoints, notes) {
var argsArray = _.toArray(arguments);
if (argsArray.length != 11) {
throw {
name: "ArgumentsException",
message: "The arguments length is incorrect."
};
}
if (!_.isDate(registered) || !_.isString(preferredBike) || !_.isNumber(bikePoints) || !_.isString(notes)) {
throw {
name: "ArgumentsException",
message: "One of the arguments does not have the expected type."
};
}
Contact.call(this, id, name, gender, company, email, phone, address);
this.type = 'client';
this.registered = registered;
this.preferredBike = preferredBike;
this.bikePoints = bikePoints;
this.notes = notes;
}
Client.prototype = Object.create(Contact.prototype);
Client.prototype.constructor = Client;
return Client;
}());