Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions cat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
var Hello = (function () {
function Hello(name) {
this.name = name;
}
Object.defineProperty(Hello.prototype, "age", {
get: function () {
return this._age;
},
set: function (value) {
this._age = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Hello.prototype, "test", {
get: function () {
return this._test;
},
set: function (value) {
this._test = value;
},
enumerable: true,
configurable: true
});
Hello.prototype.getHelloString = function () {
return "Hello, " + name + "!";
};
Hello.prototype.say = function () {
return this.getHelloString();
};
return Hello;
}());
var helloKei1 = new Hello("計");
helloKei1.age = 17;
var words = helloKei1.say();
var age = helloKei1.age;
var List = (function () {
function List() {
this.data = [];
}
List.prototype.add = function (item) {
this.data.push(item);
};
List.prototype.get = function (index) {
return this.data[index];
};
return List;
}());
var dateList = new List();
dateList.add(new Date());
var d = dateList.get(0);
var nameList = new List();
nameList.add("kei");
var n = nameList.get(0);
var str = window.prompt('入力してください');
showStr(str);
function showStr(str) {
alert(str);
}
function test() {
}
77 changes: 59 additions & 18 deletions cat.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
interface IAnimal {
name: string;
makeSound(): string;
let Hello = (function () {
function Hello(name) {
this.name = name;
}
Object.defineProperty(Hello.prototype, "age", {
get: function () {
return this._age;
},
set: function (value) {
this._age = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Hello.prototype, "test", {
get: function () {
return this._test;
},
set: function (value) {
this._test = value;
},
enumerable: true,
configurable: true
});
Hello.prototype.getHelloString = function () {
return "Hello, " + name + "!";
};
Hello.prototype.say = function () {
return this.getHelloString();
};
return Hello;
}());
let helloKei1 = new Hello("計");
helloKei1.age = 17;
let words = helloKei1.say();
let age = helloKei1.age;
let List = (function () {
function List() {
this.data = [];
}
List.prototype.add = function (item) {
this.data.push(item);
};
List.prototype.get = function (index) {
return this.data[index];
};
return List;
}());
let dateList = new List();
dateList.add(new Date());
let d = dateList.get(0);
let nameList = new List();
nameList.add("kei");
let n = nameList.get(0);
let str = window.prompt('入力してください');
showStr(str);
function showStr(str) {
alert(str);
}

class Cat implements IAnimal {
public name: string;
constructor(name: string) {
this.name = name;
}
public makeSound(): string {
return "nyaaaa";
};
function test() {
}


var myCat : IAnimal;
myCat = new Cat("kotetu");

var sound = myCat.makeSound();
Loading