Skip to content

Instantly share code, notes, and snippets.

@christopherbauer
Created April 9, 2023 04:41
Show Gist options
  • Save christopherbauer/b04325e0ad182832d2df512c3c7fd980 to your computer and use it in GitHub Desktop.
Save christopherbauer/b04325e0ad182832d2df512c3c7fd980 to your computer and use it in GitHub Desktop.
Car app typescript file
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