Skip to content
Snippets Groups Projects
Commit 9d567436 authored by Rudolf Copi Eckelberg's avatar Rudolf Copi Eckelberg
Browse files

Extending locations and simulations...

parent a6f63136
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!25Auth
Pipeline #
/* These classes are defined to allow checking of location type with the
instanceof operator. */
class Location
// Location types // Location types
class City { class City extends Location{
constructor(id) { constructor(id) {
this.id = id; this.id = id;
} }
} }
class State { class State extends Location{
constructor(id) { constructor(id) {
this.id = id; this.id = id;
} }
} }
class Region { class Region extends Location{
constructor(id) { constructor(id) {
this.id = id; this.id = id;
} }
......
...@@ -3,12 +3,16 @@ const log = require(`${libs}/log`)(module); ...@@ -3,12 +3,16 @@ const log = require(`${libs}/log`)(module);
const locations = require(`${libs}/models/locations`); const locations = require(`${libs}/models/locations`);
// Should define this somewhere else
const MAX_SIMULATION_TIME = 10;
class Simulation { class Simulation {
/* Simulation object to manage parameters and storing */ /* Simulation object to manage parameters and storing */
constructor(in_object = null) { constructor(in_object = null) {
this.name = null; this.name = null;
this.location = null; this.location = null;
this.sim_time = null; this.time = null;
this.goals = { this.goals = {
care: null, care: null,
inclusion: null, inclusion: null,
...@@ -20,6 +24,26 @@ class Simulation { ...@@ -20,6 +24,26 @@ class Simulation {
} }
} }
} }
setTime(t) {
t = parseInt(t, 10);
if(t>MAX_SIMULATION_TIME){
// Throw an error?
return;
}
this.time = t;
}
setLocation(l) {
// Should sanitize
this.location = l;
}
setCareGoals(g) {
// Should sanitize
this.goals.care = g;
}
setInclusionGoals(g) {
// Should sanitize
this.goals.inclusion = g;
}
run() { run() {
/* Runs the Simulation with given parameters */ /* Runs the Simulation with given parameters */
// if (!this.name || !this.location || !this.time) { // if (!this.name || !this.location || !this.time) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment