class ChatRoom {
public static showMessage(user: User, message: string): void {
console.log(new Date().toString()
+ " [" + user.getName() + "] : " + message);
}
}
class User {
private name: string;
public getName(): string {
return this.name;
}
public setName(name: string): void {
this.name = name;
}
constructor(name: string) {
this.name = name;
}
public sendMessage(message: string): void {
ChatRoom.showMessage(this, message);
}
}