Created
April 9, 2023 04:41
-
-
Save christopherbauer/b04325e0ad182832d2df512c3c7fd980 to your computer and use it in GitHub Desktop.
Car app typescript file
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
import { Gallons, MPG, NewCar } from "@classlibrary/core-ts"; | |
const gas = 10 as Gallons; | |
const milesToTheGallon = 15 as MPG; | |
const car = new NewCar(gas, milesToTheGallon); | |
car.start(); | |
car.drive(15); | |
car.drive(35); | |
car.drive(20); | |
car.drive(30); | |
car.drive(35); | |
car.drive(15); //out of gas! | |
car.start(); | |
car.start(); | |
const fillup = 5 as Gallons; | |
console.log(`Filling ${fillup} gallons`); | |
car.fill(fillup); | |
car.start(); | |
car.drive(15); | |
car.drive(30); | |
car.drive(10); | |
console.log("Home!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment