From 036e211ef3ba4ecbdba50d48170e148a22ff2a31 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 16:59:52 +0100 Subject: [PATCH 01/14] first task done --- src/car.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/car.js b/src/car.js index 5a72227..13cf63e 100644 --- a/src/car.js +++ b/src/car.js @@ -1,5 +1,5 @@ function Car(make, model, year, color){ - + this.year = year; } Car.prototype.sale = function(newOwner){ From 73ec3d16529ff2c0d9efdb9e27b2bad9e7e25202 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 17:01:38 +0100 Subject: [PATCH 02/14] first task done --- spec/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/test.js b/spec/test.js index de4c18b..ab1b602 100644 --- a/spec/test.js +++ b/spec/test.js @@ -18,7 +18,7 @@ describe('Car', function(){ }); describe('#state', function(){ - xit('should initially be off', function(){ + it('should initially be off', function(){ expect(myCar.state).to.equal("off"); }); }); From b82df697657c180e4955f547146faab2e9337dfc Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 17:13:42 +0100 Subject: [PATCH 03/14] second task done --- spec/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/test.js b/spec/test.js index ab1b602..d00b61c 100644 --- a/spec/test.js +++ b/spec/test.js @@ -24,13 +24,13 @@ describe('Car', function(){ }); describe('#previousOwners', function(){ - xit('should exist and initially be empty', function(){ + it('should exist and initially be empty', function(){ expect(myCar.previousOwners).to.exist.to.be.empty; }); }); describe('#currentOwner', function(){ - xit('should initially be manufacturer', function(){ + it('should initially be manufacturer', function(){ expect(myCar.currentOwner).to.equal("Manufacturer"); }); }); From 27b6ceeeeb624b5758dc3d152bde7fd464e48d64 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 17:15:00 +0100 Subject: [PATCH 04/14] third task done --- src/car.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/car.js b/src/car.js index 13cf63e..af3b6e3 100644 --- a/src/car.js +++ b/src/car.js @@ -1,5 +1,7 @@ -function Car(make, model, year, color){ - this.year = year; +function Car(make, model, year, color, state, previousOwners){ + this.year = year; + this.state = 'off'; + this.previousOwners = ''; } Car.prototype.sale = function(newOwner){ From 96298beb292422be611662e5c1f924222948fe2f Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 17:17:38 +0100 Subject: [PATCH 05/14] fourth task completed --- src/car.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/car.js b/src/car.js index af3b6e3..d4cb9b4 100644 --- a/src/car.js +++ b/src/car.js @@ -1,7 +1,8 @@ -function Car(make, model, year, color, state, previousOwners){ +function Car(make, model, year, color, state, previousOwners, currentOwner){ this.year = year; this.state = 'off'; this.previousOwners = ''; + this.currentOwner = "Manufacturer"; } Car.prototype.sale = function(newOwner){ From b64a682c7ad24147863f6746bae316afb2612cd0 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 17:20:19 +0100 Subject: [PATCH 06/14] fifth task done --- spec/test.js | 2 +- src/car.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/test.js b/spec/test.js index d00b61c..d7b507f 100644 --- a/spec/test.js +++ b/spec/test.js @@ -36,7 +36,7 @@ describe('Car', function(){ }); describe('#passengers', function(){ - xit('should exist and initially be empty', function(){ + it('should exist and initially be empty', function(){ expect(myCar.passengers).to.exist.to.be.empty; }); }); diff --git a/src/car.js b/src/car.js index d4cb9b4..a398d3b 100644 --- a/src/car.js +++ b/src/car.js @@ -1,8 +1,9 @@ -function Car(make, model, year, color, state, previousOwners, currentOwner){ +function Car(make, model, year, color, state, previousOwners, currentOwner, passengers){ this.year = year; this.state = 'off'; this.previousOwners = ''; this.currentOwner = "Manufacturer"; + this.passengers = ''; } Car.prototype.sale = function(newOwner){ From 3c039afb1c370fe8f4594e42a73232608fe397d1 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 18:33:45 +0100 Subject: [PATCH 07/14] pass the sixth task --- spec/test.js | 2 +- src/car.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/test.js b/spec/test.js index d7b507f..8c2bf0e 100644 --- a/spec/test.js +++ b/spec/test.js @@ -42,7 +42,7 @@ describe('Car', function(){ }); describe('#sale', function(){ - xit('should move currentOwner to previousOwners array', function(){ + it('should move currentOwner to previousOwners array', function(){ myCar.sale("Charlie"); expect(myCar.previousOwners[0]).to.equal("Manufacturer"); }); diff --git a/src/car.js b/src/car.js index a398d3b..7e0905d 100644 --- a/src/car.js +++ b/src/car.js @@ -1,13 +1,14 @@ function Car(make, model, year, color, state, previousOwners, currentOwner, passengers){ this.year = year; this.state = 'off'; - this.previousOwners = ''; + this.previousOwners = []; this.currentOwner = "Manufacturer"; this.passengers = ''; } Car.prototype.sale = function(newOwner){ - + this.previousOwners.push(this.currentOwner); +// i should move currentOwner to previousOwner[] }; Car.prototype.paint = function(newColor){ From 3277d3fa687a8d3c60b2e5835877a256a8a149ee Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 19:02:19 +0100 Subject: [PATCH 08/14] done 8th task --- spec/test.js | 2 +- src/car.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/test.js b/spec/test.js index 8c2bf0e..cf0b1d8 100644 --- a/spec/test.js +++ b/spec/test.js @@ -47,7 +47,7 @@ describe('Car', function(){ expect(myCar.previousOwners[0]).to.equal("Manufacturer"); }); - xit('should update currentOwner with the new owner', function(){ + it('should update currentOwner with the new owner', function(){ myCar.sale("Charlie"); expect(myCar.currentOwner).to.equal("Charlie"); }); diff --git a/src/car.js b/src/car.js index 7e0905d..2c25ad9 100644 --- a/src/car.js +++ b/src/car.js @@ -4,11 +4,15 @@ function Car(make, model, year, color, state, previousOwners, currentOwner, pass this.previousOwners = []; this.currentOwner = "Manufacturer"; this.passengers = ''; + this.newOwner = "Charlie"; } Car.prototype.sale = function(newOwner){ this.previousOwners.push(this.currentOwner); // i should move currentOwner to previousOwner[] + + this.currentOwner = newOwner; +// this function should update currentOwner with the new Owner }; Car.prototype.paint = function(newColor){ From 4d50b26c8cd30f653f11892836fb9de6a8dbc7cf Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 19:04:26 +0100 Subject: [PATCH 09/14] done 9th task --- spec/test.js | 2 +- src/car.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/test.js b/spec/test.js index cf0b1d8..8558f34 100644 --- a/spec/test.js +++ b/spec/test.js @@ -54,7 +54,7 @@ describe('Car', function(){ }); describe('#paint', function(){ - xit('should update the color of myCar', function(){ + it('should update the color of myCar', function(){ myCar.paint("Blue"); expect(myCar.color).to.equal("Blue"); }); diff --git a/src/car.js b/src/car.js index 2c25ad9..5fda5fd 100644 --- a/src/car.js +++ b/src/car.js @@ -5,6 +5,7 @@ function Car(make, model, year, color, state, previousOwners, currentOwner, pass this.currentOwner = "Manufacturer"; this.passengers = ''; this.newOwner = "Charlie"; + this.color = "Blue"; } Car.prototype.sale = function(newOwner){ From 3df2cb6bfeb819a9af7b7a08d9cf0a5feec2a185 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 19:18:12 +0100 Subject: [PATCH 10/14] 9th task done --- spec/test.js | 2 +- src/car.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/test.js b/spec/test.js index 8558f34..1933597 100644 --- a/spec/test.js +++ b/spec/test.js @@ -61,7 +61,7 @@ describe('Car', function(){ }); describe('#start', function(){ - xit('should update the state to on', function(){ + it('should update the state to on', function(){ myCar.start(); expect(myCar.state).to.equal("on"); }); diff --git a/src/car.js b/src/car.js index 5fda5fd..b5e9ccf 100644 --- a/src/car.js +++ b/src/car.js @@ -16,6 +16,10 @@ Car.prototype.sale = function(newOwner){ // this function should update currentOwner with the new Owner }; +Car.prototype.start = function(state){ + this.state = "on"; +} + Car.prototype.paint = function(newColor){ }; From 119b8755f75170c99b9087378d434c7e3afea9a1 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 19:27:14 +0100 Subject: [PATCH 11/14] 10th task done --- spec/test.js | 2 +- src/car.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/test.js b/spec/test.js index 1933597..899e1fe 100644 --- a/spec/test.js +++ b/spec/test.js @@ -68,7 +68,7 @@ describe('Car', function(){ }); describe('#off', function(){ - xit('should update the state to off', function(){ + it('should update the state to off', function(){ myCar.off(); expect(myCar.state).to.equal("off"); }); diff --git a/src/car.js b/src/car.js index b5e9ccf..c612bb4 100644 --- a/src/car.js +++ b/src/car.js @@ -20,6 +20,10 @@ Car.prototype.start = function(state){ this.state = "on"; } +Car.prototype.off = function(state){ + this.state = "off"; +} + Car.prototype.paint = function(newColor){ }; From 5ca468becdb10b34903925da747e9ff2ce676d89 Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 19:34:49 +0100 Subject: [PATCH 12/14] 11th task done --- spec/test.js | 2 +- src/car.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/test.js b/spec/test.js index 899e1fe..96d35c3 100644 --- a/spec/test.js +++ b/spec/test.js @@ -75,7 +75,7 @@ describe('Car', function(){ }); describe('#pickUp', function(){ - xit('should add the passenger to the passengers array', function(){ + it('should add the passenger to the passengers array', function(){ myCar.start(); myCar.pickUp("john"); expect(myCar.passengers[0]).to.equal("john"); diff --git a/src/car.js b/src/car.js index c612bb4..18b7906 100644 --- a/src/car.js +++ b/src/car.js @@ -3,7 +3,7 @@ function Car(make, model, year, color, state, previousOwners, currentOwner, pass this.state = 'off'; this.previousOwners = []; this.currentOwner = "Manufacturer"; - this.passengers = ''; + this.passengers = []; this.newOwner = "Charlie"; this.color = "Blue"; } @@ -24,6 +24,10 @@ Car.prototype.off = function(state){ this.state = "off"; } +Car.prototype.pickUp = function(passenger){ + this.passengers.push("john"); +} + Car.prototype.paint = function(newColor){ }; From 597dc35a47be2ebc2f5565895e6cc2c0bf17658e Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 19:52:48 +0100 Subject: [PATCH 13/14] 13 task done --- spec/test.js | 4 ++-- src/car.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/test.js b/spec/test.js index 96d35c3..baa71dd 100644 --- a/spec/test.js +++ b/spec/test.js @@ -81,7 +81,7 @@ describe('Car', function(){ expect(myCar.passengers[0]).to.equal("john"); }); - xit('should only modify passengers array if car is on', function(){ + it('should only modify passengers array if car is on', function(){ // myCar.off(); myCar.pickUp("john"); expect(myCar.passengers[0]).to.be.empty; @@ -89,7 +89,7 @@ describe('Car', function(){ }); describe('#dropOff', function(){ - xit('should remove passenger from the passengers array', function(){ + it('should remove passenger from the passengers array', function(){ myCar.start(); myCar.pickUp("john"); myCar.dropOff("john"); diff --git a/src/car.js b/src/car.js index 18b7906..adaf221 100644 --- a/src/car.js +++ b/src/car.js @@ -24,8 +24,15 @@ Car.prototype.off = function(state){ this.state = "off"; } -Car.prototype.pickUp = function(passenger){ - this.passengers.push("john"); +Car.prototype.pickUp = function(passengers){ + // this.passengers.push("john"); + if (this.state === "on"){ + this.passengers.push(passengers); + } +} + +Car.prototype.dropOff = function(passengers){ + this.passengers.shift(passengers); } Car.prototype.paint = function(newColor){ From 1a7a670c26e18bb2d4c0e038188aa483629adaaf Mon Sep 17 00:00:00 2001 From: Alberto Ferioli Date: Thu, 30 Apr 2015 19:57:41 +0100 Subject: [PATCH 14/14] 14th task --- spec/test.js | 2 +- src/car.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/test.js b/spec/test.js index baa71dd..eba5b48 100644 --- a/spec/test.js +++ b/spec/test.js @@ -96,7 +96,7 @@ describe('Car', function(){ expect(myCar.passengers).to.be.empty; }); - xit('should leave passenger in the passengers array if car is off', function(){ + it('should leave passenger in the passengers array if car is off', function(){ myCar.start(); myCar.pickUp("john"); myCar.off(); diff --git a/src/car.js b/src/car.js index adaf221..ab6a3cd 100644 --- a/src/car.js +++ b/src/car.js @@ -33,8 +33,14 @@ Car.prototype.pickUp = function(passengers){ Car.prototype.dropOff = function(passengers){ this.passengers.shift(passengers); + if(this.state === "off"){ + this.passengers.push(passengers); + } } + + + Car.prototype.paint = function(newColor){ };