-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1
More file actions
28 lines (24 loc) · 614 Bytes
/
1
File metadata and controls
28 lines (24 loc) · 614 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
interface User {
id: number;
name: string;
email: string;
isActive: boolean;
}
class UserAccount implements User {
constructor(
public id: number,
public name: string,
public email: string,
public isActive: boolean = true
) {}
toggleActive(): void {
this.isActive = !this.isActive;
}
displayInfo(): void {
console.log(`User: ${this.name}, Email: ${this.email}, Active: ${this.isActive}`);
}
}
function createUser(name: string, email: string): User {
const id = Math.floor(Math.random() * 1000); // Generate a random id
return new UserAccount(id, name, email);
}