rabbbit
2023-06-16 23:19:42 +08:00
🐶
interface Is2Interface {
is2(a: number): boolean;
}
abstract class AbstractIs2 implements Is2Interface {
is2(a: number): boolean {
return a === 2;
}
}
class Is2 extends AbstractIs2 {
is2(a: number): boolean {
if (a === 2) {
return true
} else {
return false
}
}
}
interface Is2FactoryInterface {
getIs2(): AbstractIs2;
}
abstract class AbstractIs2Factory implements Is2FactoryInterface {
getIs2(): AbstractIs2 {
return new Is2();
};
}
class Is2Factory extends AbstractIs2Factory {
private is2: AbstractIs2 = new Is2();
getIs2(): AbstractIs2 {
return this.is2;
};
}
class Main {
public static main(): void {
const is2Factory = new Is2Factory();
const is2 = is2Factory.getIs2();
const a = 2;
console.log(is2.is2(a));
}
}
Main.main();