Skip to content

Instantly share code, notes, and snippets.

@learner-long-life
Created May 12, 2015 03:54
Show Gist options
  • Save learner-long-life/3a3ac11aa727d348aec1 to your computer and use it in GitHub Desktop.
Save learner-long-life/3a3ac11aa727d348aec1 to your computer and use it in GitHub Desktop.
QbyYOq
<!DOCTYPE html>
<html>
<head>
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h1>At least one tag</h1>
<table class="table">
<thead>
<tr>
<td>Location</td>
<td>Avg Donuts Per Hour</td>
<td>Total Donuts Per Day
</td>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Downtown</td>
<td>508</td>
<td>100</td>
</tr>
<tr id="capHill">
<td>Capitol Hill</td>
<td>174</td>
<td>4704</td>
</tr>
<tr class="odd">
<td>Wedgewood</td>
<td>100</td>
<td>1000</td>
</tr>
</tbody>
</table>
</body>
</html>
function DonutShop(name, minCustomers, maxCustomers,
avgDonuts, hoursOp) {
this.name = name;
this.minCustomers = minCustomers;
this.maxCustomers = maxCustomers;
this.avgDonuts = avgDonuts;
this.hoursOp = hoursOp;
this.getRandCustPerHour = function() {
var range = this.maxCustomers - this.minCustomers + 1;
var random = Math.floor(Math.random() * range + this.minCustomers);
return random;
}
this.perHour = function() {
this.bakeHour = Math.floor(this.getRandCustPerHour() * this.avgDonuts);
return this.bakeHour;
};
this.perDay = function() {
var bakeDay = Math.floor(this.perHour() * this.hoursOp);
return bakeDay;
};
}
var downtown = new DonutShop("Downtown", 8, 43, 4.50, 8),
capitolHill = new DonutShop("Capitol Hill", 4, 37, 2.00, 24),
slu = new DonutShop("South Lake Union", 9, 23, 6.33, 10),
wedgewood = new DonutShop("Wedgewood", 2, 28, 1.25, 7),
ballard = new DonutShop("Ballard", 8, 58, 3.75, 10),
wallingford = new DonutShop("Wallingford", 1, 2, 3, 4);
function DonutMaster() {
this.newList = [];
this.addShop = function(donutShop) {
//adds a new DonutShop to a list //
this.newList.push(donutShop);
};
this.generateReport = function() {
//loops through the list of DonutShops and output location/donutperhour/donutperday //
for (var i = 0; i < this.newList.length; i++) {
console.log("The " + this.newList[i].name + " shop needs to bake " +
this.newList[i].perDay() + " donuts per day." +
this.newList[i].bakeHour + " donuts per hour.");
}
};
}
var donutMaster = new DonutMaster();
donutMaster.addShop(downtown);
donutMaster.addShop(capitolHill);
// and so on for all the donut shops
donutMaster.generateReport();
h1 {
color: red;
}
#capHill {
font-style: italic;
}
.odd {
background-color: #ccc;
}
table {
border: 10px dashed antiquewhite;
}
thead {
font-weight: bold;
background-color: pink;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment