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 29 30 31 32
| abstract class Database { static username: string = 'admin'; static password: string = '123456'; abstract getDetails(): void }
class Sql extends Database { getDetails() { console.log(Sql.username + 'Sql', Sql.password + 'Sql'); } }
class Mysql extends Database { getDetails() { console.log(Mysql.username + 'Mysql', Mysql.password + 'Mysql'); } }
class MongoDB extends Database { getDetails() { console.log(MongoDB.username + 'MongoDB', MongoDB.password + 'MongoDB'); } }
const ConnectSql = new Sql() ConnectSql.getDetails()
const ConnectMysql = new Mysql() ConnectMysql.getDetails()
const ConnectMongoDB = new MongoDB() ConnectMongoDB.getDetails()
|