summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2014-12-22 12:51:50 +0900
committerSean Whitton <spwhitton@spwhitton.name>2014-12-22 12:51:50 +0900
commit1ba2acc9e7af03f77a20408e90e7c53eb437c00a (patch)
tree3f53c45432fff80ce007501d864137e51f07f743
parent0932319d745f550968b5dec24e80d0acd5ffb768 (diff)
downloadschoolclock-1ba2acc9e7af03f77a20408e90e7c53eb437c00a.tar.gz
generalise support for giving a bonus to classes who have fewer lessons
per week
-rw-r--r--js/main.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/js/main.js b/js/main.js
index dfef356..31f6dcd 100644
--- a/js/main.js
+++ b/js/main.js
@@ -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);