From 4cea89c9463e966631f752f42c46964e1e46bd94 Mon Sep 17 00:00:00 2001 From: zackSolidd Date: Wed, 10 Jun 2020 23:30:34 +0800 Subject: [PATCH 1/2] completed how to start --- index.html | 21 ++++++--------------- script.js | 28 +++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index 5fa0cb9..154c6f0 100644 --- a/index.html +++ b/index.html @@ -3,21 +3,12 @@ - -

output:

-

- +

CheapCheap Airline

+

+

+ +

diff --git a/script.js b/script.js index 5b7b680..529c875 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,24 @@ -console.log("hello script js"); +var totalSeat = 10; +var startPrice = 50; + +document.getElementById("pricing").innerHTML = startPrice +" for your ticket"; +document.getElementById("seatLeft").innerHTML = totalSeat+" seats left"; +function buyTicket(){ + if(totalSeat <= 10 && totalSeat > 1){ + document.getElementById("thankYouMessage").innerHTML = "Thank you please pay me "+ startPrice+" NOW!" + totalSeat -= 1; + startPrice = Number(startPrice * 1.05).toFixed(2); + document.getElementById("seatLeft").innerHTML = totalSeat+" seats left"; + document.getElementById("pricing").innerHTML = startPrice +" for your ticket"; + console.log(totalSeat); + console.log(startPrice); + return startPrice; + return totalSeat; + } + else if (totalSeat == 1 ){ + document.getElementById("thankYouMessage").innerHTML = "Thank you please pay me "+ startPrice+" NOW!" + document.getElementById("pricing").innerHTML = "call us to pay big money for ticket"; + document.getElementById("seatLeft").innerHTML = "no seats left, come back tomorrow"; + } +} -var inputHappened = function(currentInput){ - console.log( currentInput ); - return "WOW SOMETHING HAPPENED"; -}; From e6797092732fece41c0c18a094634e03187fae84 Mon Sep 17 00:00:00 2001 From: zackSolidd Date: Thu, 11 Jun 2020 00:57:36 +0800 Subject: [PATCH 2/2] price increase current ticket --- index.html | 3 +++ script.js | 74 +++++++++++++++++++++++++++++++++++++++++++++++------- style.css | 4 +++ 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 154c6f0..2c9f706 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,9 @@

+ +s \ No newline at end of file diff --git a/script.js b/script.js index 529c875..932def5 100644 --- a/script.js +++ b/script.js @@ -1,24 +1,80 @@ var totalSeat = 10; -var startPrice = 50; +var startPriceFirstHalf = 50; +var startPriceSecondHalf = 50; +var totalMoneyWeEarn = 50; -document.getElementById("pricing").innerHTML = startPrice +" for your ticket"; +document.getElementById("pricing").innerHTML = startPriceFirstHalf +" for your ticket"; document.getElementById("seatLeft").innerHTML = totalSeat+" seats left"; function buyTicket(){ - if(totalSeat <= 10 && totalSeat > 1){ - document.getElementById("thankYouMessage").innerHTML = "Thank you please pay me "+ startPrice+" NOW!" + if(totalSeat <= 10 && totalSeat > 6){ + document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn; totalSeat -= 1; - startPrice = Number(startPrice * 1.05).toFixed(2); + startPriceFirstHalf = Number(startPriceFirstHalf * 1.03).toFixed(2); + var seatLeftBeforePriceIncrease = totalSeat - 5; + document.getElementById("seatLeft").innerHTML = seatLeftBeforePriceIncrease+" seats before price bracket increase"; + document.getElementById("pricing").innerHTML = startPriceFirstHalf +" for your ticket"; + totalMoneyWeEarn = parseFloat(totalMoneyWeEarn) + parseFloat(startPriceFirstHalf); + console.log(totalSeat); + console.log(startPriceFirstHalf); + console.log(totalMoneyWeEarn); + return seatLeftBeforePriceIncrease; + return totalMoneyWeEarn; + return startPriceFirstHalf; + return totalSeat; + } + if(totalSeat <= 6 && totalSeat > 2){ + document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn; + document.getElementById("pricing").innerHTML = startPriceSecondHalf +" for your ticket"; + var seatLeftBeforePriceIncrease = totalSeat - 2; + totalSeat -= 1; + totalMoneyWeEarn = parseFloat(totalMoneyWeEarn) + parseFloat(startPriceSecondHalf); + startPriceSecondHalf = Number(startPriceSecondHalf * 1.05).toFixed(2); + document.getElementById("seatLeft").innerHTML = seatLeftBeforePriceIncrease+" seats left before price bracket increase"; + console.log(totalSeat); + console.log(startPriceSecondHalf); + console.log(totalMoneyWeEarn); + return totalMoneyWeEarn; + return startPriceSecondHalf; + return totalSeat; + return seatLeftBeforePriceIncrease; + } + if(totalSeat == 2){ + document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn; + document.getElementById("pricing").innerHTML ="$91,000 for your ticket"; + totalSeat -= 1; + startPriceSecondHalf = Number(startPriceSecondHalf * 1.05).toFixed(2); document.getElementById("seatLeft").innerHTML = totalSeat+" seats left"; - document.getElementById("pricing").innerHTML = startPrice +" for your ticket"; console.log(totalSeat); - console.log(startPrice); - return startPrice; + console.log(startPriceSecondHalf); + return totalMoneyWeEarn; + return startPriceSecondHalf; return totalSeat; } else if (totalSeat == 1 ){ - document.getElementById("thankYouMessage").innerHTML = "Thank you please pay me "+ startPrice+" NOW!" + totalMoneyWeEarn += 91000; + document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn; document.getElementById("pricing").innerHTML = "call us to pay big money for ticket"; document.getElementById("seatLeft").innerHTML = "no seats left, come back tomorrow"; + totalSeat -= 1; + } + else{ + document.getElementById("thankYouMessage").innerHTML = "No ticket means no ticket"; + } +} + +function admin(){ + var password = prompt("Please enter password"); + if (password === "password1"){ + totalSeat = 10; + startPriceFirstHalf = 50; + startPriceSecondHalf = 50; + totalMoneyWeEarn = 50; + document.getElementById("pricing").innerHTML = startPriceFirstHalf +" for your ticket"; + document.getElementById("seatLeft").innerHTML = totalSeat+" seats left"; + document.getElementById("thankYouMessage").innerHTML = ""; + } + else { + document.getElementById("thankYouMessage").innerHTML = "wrong"; } } diff --git a/style.css b/style.css index 282077b..47002ee 100644 --- a/style.css +++ b/style.css @@ -1,3 +1,7 @@ +body{ + background-color: white; +} + .starter{ font-size:30px; padding:10px;