diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2014-12-22 12:51:50 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2014-12-22 12:51:50 +0900 |
commit | 1ba2acc9e7af03f77a20408e90e7c53eb437c00a (patch) | |
tree | 3f53c45432fff80ce007501d864137e51f07f743 /js | |
parent | 0932319d745f550968b5dec24e80d0acd5ffb768 (diff) | |
download | schoolclock-1ba2acc9e7af03f77a20408e90e7c53eb437c00a.tar.gz |
generalise support for giving a bonus to classes who have fewer lessons
per week
Diffstat (limited to 'js')
-rw-r--r-- | js/main.js | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -6,9 +6,10 @@ // // class: one of the classes in our school -var Class = function (grade, clas, total) { +var Class = function (grade, clas, total, modifier) { this.grade = grade; this.clas = clas; + this.modifier = modifier; // human-readable ID this.id = this.grade + '-' + this.clas; this.total = total; @@ -36,12 +37,13 @@ Class.prototype.changeTime = function (change) { // now set up all our classes var classes = [ - new Class(5, 1, 30), - new Class(5, 2, 30), - new Class(5, 3, 30), - new Class(6, 1, 19), - new Class(6, 2, 18), - new Class(6, 3, 19) + new Class(5, 1, 25, 1.5), + new Class(5, 2, 25, 1.5), + new Class(5, 3, 25, 1.5), + new Class(6, 1, 25, 1), + new Class(6, 2, 25, 1), + new Class(6, 3, 25, 1), + new Class(6, 4, 25, 1) ]; // method to sort them @@ -118,8 +120,8 @@ function updateClasses () var change = parseInt(prompt("Change points by how much?", 0)); // give grade 5 their bonus - if (clas.grade == 5) - change = change * 1.5; + var multiplier = parseFloat(prompt("Multiplier to previous change?", clas.modifier)) + change = parseInt(change * multiplier); // modify class points classes[index].changePoints(change); |