Last active
August 29, 2015 14:27
-
-
Save brookr/4f73f349db2306342e8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Rick's Top Pot Solution</title> | |
<style type="text/css"> | |
body { | |
color: #222; | |
} | |
li { | |
color: green; | |
} | |
li a{ | |
color: red; | |
} | |
.hot { | |
color: purple; | |
} | |
#callout { | |
font-variant: small-caps; | |
} | |
</style> | |
</head> | |
<body style="background-image: url(http://rampantcuisine.com/wp-content/uploads/2013/06/DONUT-WITH-SPRINKLES.jpg); background-size: 100%"> | |
<input type = "button" onClick = "dm.addShop();" value = "Add Shop?" /> | |
<nav> | |
<ul> | |
<li><p class="hot">Text:</p> | |
<a href="">LINK!!</a> | |
</li> | |
<li>Text: | |
<a href="">LINK!!</a> | |
</li> | |
<li>Text: | |
<a href="">LINK!!</a> | |
</li> | |
<li class="hot">Text: | |
<a href="">LINK!!</a> | |
</li> | |
<li id="callout" class="hot">Text: | |
<a href="">LINK!!</a> | |
</li> | |
<li class="hot">Text: | |
<a href="">LINK!!</a> | |
</li> | |
<li class="hot"> Text: | |
<a href="">LINK!!</a> | |
</li> | |
<li class="hot"> | |
<a href="">LINK!!</a> | |
</li> | |
</ul> | |
</nav> | |
<table id = "donutTable" border = "1" style = "width: 100%"> | |
<tr> | |
<th>Location</th> | |
<th>Hours Open</th> | |
<th>Avg Customers per Hour</th> | |
<th>Donuts per Customer</th> | |
<th bgcolor="#AE9901">Donuts Made per Hour</th> | |
<th bgcolor="#AE9901">Donuts Made per Day</th> | |
</tr> | |
<script> | |
//create a custom constructor function to accept necessary parameters of each store's info | |
var Shop = function (location, hoursOpen, custPerHourMin, custPerHourMax, donutsPerCust) { | |
this.loc = location; | |
this.hours = hoursOpen; | |
this.custMin = custPerHourMin; | |
this.custMax = custPerHourMax; | |
this.donuts = donutsPerCust; | |
this.custAvg = Math.floor(Math.random() * (this.custMax - this.custMin + 1) + this.custMin); | |
this.donutsPerHr = Math.ceil(this.custAvg * this.donuts); | |
this.donutsPerDay = this.donutsPerHr * this.hours; | |
//create a method that lists out what we need to know for each store! | |
this.tellMeSomethingGood = function (){ | |
console.log(this.loc + ":\n" + this.custAvg + " customers per hour.\n" + this.donuts + " average donuts per customer.\n" + "Open " + this.hours + " hours a day.\n\n" + this.donutsPerHr + " donuts to be made per hour.\n" + this.donutsPerDay + " donuts to be made today!\n\n"); | |
return document.write("<tr>" + "<td>" + this.loc + "<td align = 'center'>" + this.hours + "<td align = 'center'>" + this.custAvg + "<td align = 'center'>" + this.donuts + "<td align = 'center' bgcolor = '#AE9901'>" + this.donutsPerHr + "<td align = 'center' bgcolor = '#AE9901'>" + this.donutsPerDay); | |
}; | |
}; | |
var DonutMaster = function() { | |
this.locations = ["Downtown", "Capitol Hill", "SLU", "Ballard", "Wedgewood"]; | |
this.hours = [24, 12, 12, 10, 10]; | |
this.minCust = [8, 4, 9, 8, 2]; | |
this.maxCust = [43, 37, 23, 58, 28]; | |
this.donutsPer = [4.5, 2, 6.33, 3.75, 1.25]; | |
this.shops = []; | |
this.addShop = function (){ | |
this.locations.push(prompt("Enter a location")); | |
this.hours.push(prompt("Enter total hours open per day")); | |
this.minCust.push(prompt("Enter avg customers per hour minimum")); | |
this.maxCust.push(prompt("Enter avg customers per hour maximum")); | |
this.donutsPer.push(prompt("Enter avg donuts purchased per customer")); | |
}; | |
this.buildShops = function() { | |
this.shops = []; | |
for (var listOut = 0; listOut < this.locations.length; listOut ++){ | |
this.shops.push(new Shop(this.locations[listOut], this.hours[listOut], this.minCust[listOut], this.maxCust[listOut], this.donutsPer[listOut])); | |
} | |
}; | |
this.showShops = function() { | |
for (var i = 0; i < this.shops.length; i++) { | |
this.shops[i].tellMeSomethingGood(); | |
}; | |
} | |
} | |
var dm = new DonutMaster(); | |
dm.buildShops(); | |
dm.showShops(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment