-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPotholeCollectionObject.js
22 lines (22 loc) · 1.24 KB
/
PotholeCollectionObject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Function that initializes a pothole collection object.
* Parameters:
* • toBeMeasured : an Array of coordinates (or locations) of potholes to be measured
* • toBeInspected: an Array of coordinates (or locations) of potholes to be inspected
* • toBeFilled : an Array of coordinates (or locations) of potholes to be filled
* • filled : an Array of coordinates (or locations) of potholes that are filled
* Returns:
* • an object that contains the arrays specified by the arguments
*/
function PotholeCollectionObject(toBeMeasured, toBeInspected, toBeFilled, filled)
{
// verify that all the parameters are arrays or things that are falsy (null, undefined, false, ...)
if ((toBeMeasured) &&(!Array.isArray(toBeMeasured))) return null;
if ((toBeInspected) && (!Array.isArray(toBeInspected))) return null;
if ((toBeFilled) && (!Array.isArray(toBeFilled))) return null;
if ((filled) && (!Array.isArray(filled))) return null;
// build this
this.toBeMeasured = (toBeMeasured === undefined) ? [] : toBeMeasured;
this.toBeInspected = (toBeInspected === undefined) ? [] : toBeInspected;
this.toBeFilled = (toBeFilled === undefined) ? [] : toBeFilled;
this.filled = (filled === undefined) ? [] : filled;
}