Created
June 22, 2020 19:09
-
-
Save softwarebygabe/4d1a708c341fa29defb2d84b7bd5e10e to your computer and use it in GitHub Desktop.
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
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