CHALLENGE 1: Create a Vehicle Class ==================================== SOLUTION: class Vehicle { public brand: string; public model: string; public year: number; constructor(brand: string, model: string, year: number) { this.brand = brand; this.model = model; this.year = year; } getInfo(): string { return `${this.year} ${this.brand} ${this.model}`; } } // Create instances const car1 = new Vehicle("Toyota", "Camry", 2022); const car2 = new Vehicle("Honda", "Civic", 2021); const car3 = new Vehicle("Tesla", "Model 3", 2023); // Use the method console.log(car1.getInfo()); // Output: 2022 Toyota Camry console.log(car2.getInfo()); // Output: 2021 Honda Civic console.log(car3.getInfo()); // Output: 2023 Tesla Model 3 ALTERNATIVE (Using Constructor Shorthand): class Vehicle { constructor( public brand: string, public model: string, public year: number ) {} getInfo(): string { return `${this.year} ${this.brand} ${this.model}`; } } // Same usage, same results! EXPLANATION: - "class Vehicle { }" — defines a blueprint - "public brand: string" — properties are public (accessible from outside) - "constructor(brand, model, year)" — runs when you create new Vehicle(...) - "this.brand = brand" — assigns the parameter to the property - "getInfo()" — method that returns a string - "new Vehicle(...)" — creates an instance WHY CLASSES: - Encapsulation: group related data and methods - Reusability: create many vehicles from one class - Type safety: TypeScript knows each Vehicle has brand, model, year - Organization: cleaner than having individual objects