Skip to content

Instantly share code, notes, and snippets.

@softwarebygabe
Created June 22, 2020 19:09
Show Gist options
  • Save softwarebygabe/4d1a708c341fa29defb2d84b7bd5e10e to your computer and use it in GitHub Desktop.
Save softwarebygabe/4d1a708c341fa29defb2d84b7bd5e10e to your computer and use it in GitHub Desktop.
type Material = 'wood' | 'brick' | 'steel'
class House {
private rooms: number
private floors: number
private material: Material
private bathrooms: number
private squareFootage: number
private address: string
private constructionDate: Date
constructor(rooms: number, floors: number, material: Material, squareFootage: number, address: string, constructionDate: Date) {
if (rooms < 1) {
throw new Error('invalid number of rooms!')
}
this.rooms = rooms
if (floors < 1) {
throw new Error('invalid number of floors!')
}
this.floors = floors
this.material = material
// etc ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment