Skip to content

Feature/birthdays #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1afa1b2
Add all functions
Denzel-Turambi Mar 27, 2023
ed39756
Remove all skips
Denzel-Turambi Mar 27, 2023
a39e2c4
Add package-lock.json
Denzel-Turambi Mar 27, 2023
8755ea2
Finalize dragon implementation file
Denzel-Turambi Mar 28, 2023
d076889
Merge pull request #1 from Denzel-Turambi/feature/dragon
Denzel-Turambi Mar 28, 2023
b9be127
Complete vampire implementation file
Denzel-Turambi Mar 28, 2023
e3e58d9
Remove all the skips
Denzel-Turambi Mar 28, 2023
f52b3a3
Merge pull request #2 from Denzel-Turambi/feature/vampire
Denzel-Turambi Mar 28, 2023
cb1ed07
Added 4/5 functions still work in progress
Denzel-Turambi Mar 29, 2023
bf90031
Complete hobbit implementation file
Denzel-Turambi Mar 29, 2023
979bb89
Remove all skips
Denzel-Turambi Mar 29, 2023
0f00776
Merge pull request #3 from Denzel-Turambi/feature/hobbit
Denzel-Turambi Mar 29, 2023
52322b8
Add all the functions, still solving the last one
Denzel-Turambi Apr 3, 2023
2520505
Remove all skips
Denzel-Turambi Apr 4, 2023
03bc529
Airport Schmairport
Denzel-Turambi Apr 6, 2023
7671267
Complete Airport implementation file
Denzel-Turambi Apr 6, 2023
7c7b98a
Merge pull request #4 from Denzel-Turambi/feature/airport
Denzel-Turambi Apr 6, 2023
954435e
Add createBarber and giveCompliment function
Denzel-Turambi Apr 6, 2023
4ae1dc4
Remove first four skips
Denzel-Turambi Apr 6, 2023
ca8b078
AHHhhhhh
Denzel-Turambi Apr 7, 2023
8822d9f
change perameter name from customer to barber
Denzel-Turambi Apr 13, 2023
311f333
Complete and solve birthday test
Denzel-Turambi Apr 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions airport/airport-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ var assert = require('chai').assert;
var { createAirport, welcomeGuests, landPlanes, checkAirlineLocations } = require('./airport');

describe('Airport', function() {
it.skip('should create an airport', function() {
it('should create an airport', function() {
var airport = createAirport('Denver International Airport', ['United', 'Southwest', 'Delta'], 144);

assert.equal(airport.name, 'Denver International Airport');
assert.equal(airport.availableGates, 144);
assert.equal(airport.airlines[0], 'United');
});

it.skip('should welcome people to the airport', function() {
it('should welcome people to the airport', function() {
var denverAirport = createAirport('Denver International Airport', ['United', 'Southwest', 'Delta'], 144);
var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48);

Expand All @@ -22,7 +22,7 @@ describe('Airport', function() {
assert.equal(sanDiegoWelcome, 'Welcome to San Diego International Airport!');
});

it.skip('should keep track of open gates', function() {
it('should keep track of open gates', function() {
var bakersfieldAirport = createAirport('Meadows Field Airport', ['United', 'American'], 12);
var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48);

Expand All @@ -33,7 +33,7 @@ describe('Airport', function() {
assert.equal(sanDiegoAirport.availableGates, 46);
});

it.skip('should not be able to occupy more gates than available', function() {
it('should not be able to occupy more gates than available', function() {
var columbusAiport = createAirport('John Glenn Airport', ['Southwest', 'Frontier'], 24);

var occupiedGates1 = landPlanes(columbusAiport, 22);
Expand All @@ -47,7 +47,7 @@ describe('Airport', function() {
assert.equal(occupiedGates2, 'Oh no! Not enough gates available. Current overflow is 1.')
});

it.skip('should be able to tell you where an airline flies to', function() {
it('should be able to tell you where an airline flies to', function() {
var columbusAiport = createAirport('John Glenn Airport', ['Southwest', 'Frontier'], 24);
var bakersfieldAirport = createAirport('Meadows Field Airport', ['United', 'American'], 12);
var sanDiegoAirport = createAirport('San Diego International Airport', ['Frontier', 'American'], 48);
Expand Down
38 changes: 34 additions & 4 deletions airport/airport.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
function createAirport(name, airlines, availableGates) {
var airport = {
name,
airlines,
availableGates,
}
return airport;
};

function welcomeGuests(airport) {
return `Welcome to ${airport.name}!`
};

function landPlanes(airport, planesLandedCt) {
airport.availableGates -= planesLandedCt;
if (airport.availableGates > 0) {
return `Success! Current availability is ${airport.availableGates}.`
} else if (airport.availableGates < 0){
airport.availableGates = 0;
return `Oh no! Not enough gates available. Current overflow is 1.`
}
};

function checkAirlineLocations(allAirports, airline) {
var flightLocations = [];
for (var i = 0; i < allAirports.length; i++) {
if (allAirports[i].airlines.includes(airline)) {
flightLocations.push(allAirports[i].name)
}
}
return flightLocations;
};

module.exports = {
// createAirport,
// welcomeGuests,
// landPlanes,
// checkAirlineLocations
createAirport,
welcomeGuests,
landPlanes,
checkAirlineLocations
};
10 changes: 5 additions & 5 deletions barber-shop/barber-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ var assert = require('chai').assert;
var { createBarber, giveCompliment, cutHair, listStyles } = require('./barber');

describe('Barber', function() {
it.skip('should create a barber with a name', function() {
it('should create a barber with a name', function() {
var sam = createBarber('Sam');

assert.equal(sam.name, 'Sam');
})

it.skip('should be able to have earnings and known haircuts', function() {
it('should be able to have earnings and known haircuts', function() {
var cut1 = { style: 'mohawk', hairLength: 'short', price: 11.00 };
var cut2 = { style: 'side part', hairLength: 'medium', price: 12.00 };

Expand All @@ -19,7 +19,7 @@ describe('Barber', function() {
assert.deepEqual(erin.haircuts, [cut1, cut2]);
});

it.skip('should default to no earnings and no haircuts if none provided', function() {
it('should default to no earnings and no haircuts if none provided', function() {
var buzzCut = { style: 'buzz', hairLength: 'short', price: 8.00 };
var nick = createBarber('Nick', 8.00, [buzzCut]);

Expand All @@ -32,7 +32,7 @@ describe('Barber', function() {
assert.deepEqual(pam.haircuts, []);
});

it.skip('should be able to offer a compliment', function() {
it('should be able to offer a compliment', function() {
var mohawkCut = { style: 'mohawk', hairLength: 'short', price: 11.00 };
var buzzCut = { style: 'buzz', hairLength: 'short', price: 8.00 };

Expand All @@ -45,7 +45,7 @@ describe('Barber', function() {
assert.equal(buzzCompliment, 'This buzz looks great!');
});

it.skip('should be able to cut hair', function() {
it('should be able to cut hair', function() {
var matt = createBarber('Matt');

var mohawkCut = { style: 'mohawk', hairLength: 'short', price: 11.00 };
Expand Down
22 changes: 21 additions & 1 deletion barber-shop/barber.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
function createBarber(name, earnings, haircuts) {
var barber = {
name,
earnings: earnings || 0,
haircuts: haircuts || [],
}
return barber;
}

function giveCompliment(hairStyle) {
return `This ${hairStyle.style} looks great!`;
}

module.exports = { };
function cutHair(barber, hairStyle) {
var haircuts = [];

}

module.exports = {
createBarber,
giveCompliment,
cutHair
};
6 changes: 3 additions & 3 deletions birthdays/birthdays-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var assert = require('chai').assert;
var { createBirthday, celebrateBirthday, countBirthdays } = require('./birthdays');

describe('Birthdays', function() {
it.skip('should create birthdays', function() {
it('should create birthdays', function() {
var leahBirthday = createBirthday('Leah', 2, 10);
var christyBirthday = createBirthday('Christy', 3, 8);

Expand All @@ -15,7 +15,7 @@ describe('Birthdays', function() {
assert.deepEqual(christyBirthday.day, 8);
});

it.skip('should celebrate birthdays', function() {
it('should celebrate birthdays', function() {
var alexBirthday = createBirthday('Alex', 5, 19);

var celebrateAlex = celebrateBirthday(alexBirthday);
Expand All @@ -29,7 +29,7 @@ describe('Birthdays', function() {
assert.equal(celebrateHeather, 'Today is 6/29! Happy birthday, Heather!');
})

it.skip('should count how many birthdays are in a given month', function() {
it('should count how many birthdays are in a given month', function() {
var leahBirthday = createBirthday('Leah', 2, 10);
var christyBirthday = createBirthday('Christy', 3, 8);
var alexBirthday = createBirthday('Alex', 5, 19);
Expand Down
26 changes: 25 additions & 1 deletion birthdays/birthdays.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
function createBirthday(name, month, day) {
var birthdayInfo = {
name,
month,
day
}
return birthdayInfo;
};

function celebrateBirthday(birthdayInfo) {
return `Today is ${birthdayInfo.month}/${birthdayInfo.day}! Happy birthday, ${birthdayInfo.name}!`
};

module.exports = { };
function countBirthdays(birthdaysArray, month) {
var counter = 0;
for (var i = 0; i < birthdaysArray.length; i++) {
if (birthdaysArray[i].month === month)
counter += 1;
}
return counter;
};

module.exports = {
createBirthday,
celebrateBirthday,
countBirthdays
};
39 changes: 35 additions & 4 deletions mythical-creatures/exercises/dragon.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
function createDragon(name, rider, temperment) {
dragonInfo = {
name,
rider,
temperment,
timesEaten: 0,
hungry: true
};
return dragonInfo;
};

function greetRider(dragonInfo) {
return `Hi, ${dragonInfo.rider}!`
}

function eat(dragonInfo) {
dragonInfo.timesEaten += 1;
if (dragonInfo.timesEaten >= 3) {
dragonInfo.hungry = false
}
return dragonInfo;
}

function findFireBreathers(allDragons) {
var fireBreathers = [];
for (var i = 0; i < allDragons.length; i++) {
if (allDragons[i].temperment === 'aggressive') {
fireBreathers.push(allDragons[i]);
}
}
return fireBreathers;
};

module.exports = {
// createDragon,
// greetRider,
// eat,
// findFireBreathers
createDragon,
greetRider,
eat,
findFireBreathers
}
55 changes: 50 additions & 5 deletions mythical-creatures/exercises/hobbit.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,54 @@
function createHobbit(name, age) {
var hobbit = {
name: name || 'unknown',
age: age || 0,
isAdult: false,
isOld: false,
acquaintances: []
}
return hobbit;
};

function celebrateBirthday(hobbit) {
hobbit.age += 1;
if (hobbit.age > 32) {
hobbit.isAdult = true;
}
if (hobbit.age >= 101) {
hobbit.isOld = true;
}
return hobbit;
};

function getRing(hobbit) {
if (hobbit.name === 'Frodo') {
return 'Here is the ring!';
} else {
return 'You can\'t have it!';
}
};

function meetPeople(hobbit, people) {
for (var i = 0; i < people.length; i++) {
hobbit.acquaintances.push(people[i]);
}
return hobbit;
};

function findFriends(hobbit) {
var friends = [];
for (var i = 0; i < hobbit.acquaintances.length; i++) {
if (hobbit.acquaintances[i].relationship === 'friend') {
friends.push(hobbit.acquaintances[i].name)
}
}
return friends;
};

module.exports = {
// createHobbit,
// celebrateBirthday,
// getRing,
// meetPeople,
// findFriends
createHobbit,
celebrateBirthday,
getRing,
meetPeople,
findFriends
}
54 changes: 49 additions & 5 deletions mythical-creatures/exercises/vampire.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,53 @@
function createVampire(name, pet) {
var vampire = {
name,
pet: pet || 'bat',
thirsty: true,
ouncesDrank: 0
}
return vampire;
};

function encounterDeliciousVictim(vampire) {
if (vampire.thirsty === true){
return `I WANT TO SUCK YOUR BLOOD!`
} else {
return `No thanks, I am too full.`
}
}

function drink(vampire) {
if (vampire.thirsty === true) {
vampire.ouncesDrank += 10;
}
if (vampire.ouncesDrank === 50) {
vampire.thirsty = false;
}
return vampire;
};

function inquirePlace(locations, cityName) {
if (locations.includes(cityName)) {
return `Yes, I have spent some time in ${cityName}.`
} else {
return `No, I have never been to ${cityName}.`
}
}

function findBatLovers(vampires) {
var batLovers = [];
for (var i = 0; i < vampires.length; i++) {
if (vampires[i].pet === 'bat') {
batLovers.push(vampires[i].name);
}
}
return batLovers;
};

module.exports = {
// createVampire,
// drink,
// findBatLovers,
// encounterDeliciousVictim,
// inquirePlace
createVampire,
drink,
findBatLovers,
encounterDeliciousVictim,
inquirePlace
}
Loading