Skip to content

Instantly share code, notes, and snippets.

@inquisitivequin
Created May 6, 2015 04:06
Show Gist options
  • Save inquisitivequin/7b79d01929c6c12c0bc5 to your computer and use it in GitHub Desktop.
Save inquisitivequin/7b79d01929c6c12c0bc5 to your computer and use it in GitHub Desktop.
cls3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Donut shop</title>
<style type="text/css">
body {
text-align: center;
}
table {
color: #2521a0;
margin-top: 30px;
}
td {
text-align: center;
}
</style>
</head>
<body>
<header>
<h1>McDugals Donuts</h1>
<h2>Best donuts in Dugal</h2>
</header>
<article>I wrote a constructor function with the needed parameters to create instances of donut shop. As well as the parameters need to construct a method that returns the number of donuts a specific shop needs to make and hour and in a day. The number of donuts needing to me made is returned by a method written inside the donut shop constructor.</article>
<table>
<tr>
<th>Location</th>
<th>Minimum Customers Per Hour</th>
<th>Maximum Customers Per Hour</th>
<th>Average Dounts Per Customer</th>
<th>Hours of operation</th>
</tr>
<tr>
<th scope="row">Downtown</th>
<td>8</td>
<td>43</td>
<td>4.50</td>
<td>1:00 - 22:00</td>
</tr>
<tr>
<th scope="row">Capitol Hill</th>
<td>4</td>
<td>37</td>
<td>2.00</td>
<td>6:00 - 4:30</td>
</tr>
<tr>
<th scope="row">South Lake Union</th>
<td>9</td>
<td>23</td>
<td>6.33</td>
<td>8:00 - 9:30</td>
</tr>
<tr>
<th scope="row">Wedgewood</th>
<td>2</td>
<td>28</td>
<td>1.25</td>
<td>7:22 - 21:07</td>
</tr>
<tr>
<th scope="row">Ballard</th>
<td>8</td>
<td>58</td>
<td>3.75</td>
<td>3:00 - 7:00</td>
</tr>
</table>
<script type="text/javascript">
//Function constructor to build a donut shop
function donutShop(local, minCustomers, maxCustomers, avgDonutsCstmr, hoursOp) {
this.local = local;
this.minCustomers = minCustomers;
this.maxCustomers = maxCustomers;
this.avgDonutsCstmr = avgDonutsCstmr;
this.hoursOp = hoursOp;
//Generates random customer per hour from max and min customers
var customerPerHour = Math.floor(Math.random() * (maxCustomers - minCustomers + 1) + maxCustomers);
//Function to generate donuts per hour and per day
this.numOfDonuts = function() {
var donutsPerHr = Math.floor(customerPerHour * avgDonutsCstmr);
var donutsPerDay = Math.floor(donutsPerHr * this.hoursOp);
//Log results to console
console.log("The " + this.local + " donut shop needs to make " + donutsPerHr + " per hour, and " + donutsPerDay + " per day.");
}
}
//
var dwntwn = new donutShop('Downtown', 8, 43, 4.50, 8);
var capHil = new donutShop('Capitol Hill', 4, 37, 2.00, 7);
var slu = new donutShop('South Lake Union', 9, 23, 6.33, 4);
var wdgwd = new donutShop('Wedgewood', 2, 28, 1.25, 5);
var blrd = new donutShop('Ballard', 8, 58, 3.75, 6);
dwntwn.numOfDonuts();
capHil.numOfDonuts();
slu.numOfDonuts();
wdgwd.numOfDonuts();
blrd.numOfDonuts();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment