Skip to content

Commit 00e29ca

Browse files
committed
Use a class
1 parent e2fbdbf commit 00e29ca

5 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.Book = void 0;
4+
class Book {
5+
constructor(t, a) {
6+
this.getBook = () => {
7+
return `${this.title} ${this.author}`;
8+
};
9+
this.title = t;
10+
this.author = a;
11+
}
12+
}
13+
exports.Book = Book;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.Book = void 0;
4+
class Book {
5+
constructor(t, a) {
6+
this.getBook = () => {
7+
return `${this.title} ${this.author}`;
8+
};
9+
this.title = t;
10+
this.author = a;
11+
}
12+
}
13+
exports.Book = Book;

typescript/startOver/dist/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const someFunctions_1 = require("./someFunctions");
4+
const classes_1 = require("./classes");
45
let x = "Some String";
56
console.log((0, someFunctions_1.myFun)("Hello"));
67
(0, someFunctions_1.printArray)([1, 2, 3]);
78
(0, someFunctions_1.printOrPrameters)("car");
89
const p = { name: "Maria", age: 45 };
910
(0, someFunctions_1.printPerson)(p);
11+
const b = new classes_1.Book("ON THE EDGE", "Nate Silver");
12+
console.log(b.getBook());
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export class Book {
2+
private title: string
3+
private author: string
4+
5+
constructor(t: string, a: string) {
6+
this.title = t
7+
this.author = a
8+
}
9+
10+
public getBook = () => {
11+
return `${this.title} ${this.author}`;
12+
}
13+
}

typescript/startOver/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { myFun, printArray, printOrPrameters, printPerson } from "./someFunctions"
22
import { Person } from "./interfaces"
3+
import { Book } from "./classes"
34

45
let x = <string>"Some String"
56

@@ -10,5 +11,7 @@ printOrPrameters("car")
1011
const p: Person = {name: "Maria", age: 45}
1112
printPerson(p)
1213

14+
const b: Book = new Book("ON THE EDGE","Nate Silver")
15+
console.log(b.getBook())
1316

1417

0 commit comments

Comments
 (0)