Skip to content

Commit 4b007c0

Browse files
committed
#7 add new resources.
1 parent d4b1a74 commit 4b007c0

File tree

6 files changed

+82
-0
lines changed

6 files changed

+82
-0
lines changed

typescript/apps/app2/clsdir/person.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export class Person {
2+
name: string;
3+
age: number;
4+
address: string;
5+
6+
constructor(name: string, age: number, address: string) {
7+
this.name = name;
8+
this.age = age;
9+
this.address = address;
10+
}
11+
12+
private sayName(): void {
13+
console.log("My name is " + this.name + "!");
14+
}
15+
16+
public getName(): string {
17+
this.sayName();
18+
return this.name;
19+
}
20+
}

typescript/apps/app2/hello.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Hello,typescript!");

typescript/apps/app2/main.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Person } from './clsdir/person.ts'
2+
3+
const p1 = new Person('takeshi', 14, 'tokyo');
4+
var name:string = p1.getName();
5+
6+
console.log("His name is " + name + ".");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Person } from './person.ts';
2+
3+
export class BusinessPerson implements Person {
4+
private name: string;
5+
private age: number;
6+
protected address: string;
7+
private country: string;
8+
private job: string;
9+
10+
11+
public constructor(name:string, age:number,
12+
address:string, country:string, job:string) {
13+
this.name = name;
14+
this.age = age;
15+
this.address = address;
16+
this.country = country;
17+
this.job = job;
18+
}
19+
20+
public introduce(): void {
21+
console.log("Nice to meet you.");
22+
console.log("My name is " + this.name + ". I'm " + this.age + " years old.");
23+
console.log("I'm now live in " + this.country + ", at " + this.address + ". ");
24+
console.log("I'm work as " + this.job);
25+
}
26+
27+
public getName(): string {
28+
return this.name;
29+
}
30+
public getAge(): number {
31+
return this.age;
32+
}
33+
public getAddress(): string {
34+
return this.address;
35+
}
36+
public getCountry(): string {
37+
return this.country;
38+
}
39+
}

typescript/apps/app3/clsdir/person.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export interface Person {
2+
3+
getName():string;
4+
5+
getAge():number;
6+
7+
getAddress():string;
8+
9+
getCountry():string;
10+
}

typescript/apps/app3/main.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { BusinessPerson } from './clsdir/business_person.ts'
2+
3+
const bp1 = new BusinessPerson("takeshi", 14 , "tokyo", "Japan", "student");
4+
5+
bp1.introduce();
6+
var name:string = bp1.getName();

0 commit comments

Comments
 (0)