题目:

了解神话故事盘古开天辟地或者女娲开世造物,通过typescript程序模拟出天地的变化过程或者万物的衍生过程

参考博客园大神: https://www.cnblogs.com/tansm/p/TypeScript_Handbook.html

https://www.runoob.com/w3cnote/getting-started-with-typescript.html

不知道这个题目是要做什么的,我瞎想了下面的程序:

class Pangu {
static welcome01 = "开天辟地了";
welcome02: string;
welcome03() {
if (this.welcome02) {
return "Hello, " + this.welcome02;
}
else {
return Pangu.welcome01;
}
}
} var welcome04: Pangu;
welcome04 = new Pangu();
alert(welcome04.welcome03()); var welcome05: typeof Pangu = Pangu;
welcome05.welcome01 = "盘古的呼吸变成了天"; var welcome06:Pangu = new welcome05();
alert(welcome06.welcome03()); var welcome07: typeof Pangu = Pangu;
welcome07.welcome01 = "盘古的声音变成了大地"; var welcome08:Pangu = new welcome05();
alert(welcome08.welcome03()); var welcome09: typeof Pangu = Pangu;
welcome09.welcome01 = "盘古的眼睛变成了云"; var welcome10:Pangu = new welcome05();
alert(welcome10.welcome03()); var welcome11: typeof Pangu = Pangu;
welcome11.welcome01 = "盘古的四肢变成了雷声"; var welcome12:Pangu = new welcome05();
alert(welcome12.welcome03()); var welcome13: typeof Pangu = Pangu;
welcome13.welcome01 = "盘古的肌肤变成了太阳和月亮"; var welcome14:Pangu = new welcome05();
alert(welcome14.welcome03()); var welcome15: typeof Pangu = Pangu;
welcome15.welcome01 = "盘古的血液变成了江河"; var welcome16:Pangu = new welcome05();
alert(welcome16.welcome03());

  

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TypeScipt作业</title>
<script type="text/javascript" src="homework.js"></script>
</head>
</html>

  

编译之后的js

var Pangu = /** @class */ (function () {
function Pangu() {
}
Pangu.prototype.welcome03 = function () {
if (this.welcome02) {
return "Hello, " + this.welcome02;
}
else {
return Pangu.welcome01;
}
};
Pangu.welcome01 = "开天辟地了";
return Pangu;
}());
var welcome04;
welcome04 = new Pangu();
alert(welcome04.welcome03());
var welcome05 = Pangu;
welcome05.welcome01 = "盘古的呼吸变成了天";
var welcome06 = new welcome05();
alert(welcome06.welcome03());
var welcome07 = Pangu;
welcome07.welcome01 = "盘古的声音变成了大地";
var welcome08 = new welcome05();
alert(welcome08.welcome03());
var welcome09 = Pangu;
welcome09.welcome01 = "盘古的眼睛变成了云";
var welcome10 = new welcome05();
alert(welcome10.welcome03());
var welcome11 = Pangu;
welcome11.welcome01 = "盘古的四肢变成了雷声";
var welcome12 = new welcome05();
alert(welcome12.welcome03());
var welcome13 = Pangu;
welcome13.welcome01 = "盘古的肌肤变成了太阳和月亮";
var welcome14 = new welcome05();
alert(welcome14.welcome03());
var welcome15 = Pangu;
welcome15.welcome01 = "盘古的血液变成了江河";
var welcome16 = new welcome05();
alert(welcome16.welcome03());
class Name {
name : string; constructor(name) {
this.name = name;
}
} class EarthSkyItem extends Name {
private bodyItem : BodyItem;
private sky : Sky;
private earth : Earth;
constructor(name:string, bodyItem : BodyItem, sky : Sky, earth : Earth) {
super(name);
this.bodyItem = bodyItem;
this.sky = sky;
this.earth = earth;
} } class Wind extends EarthSkyItem {
constructor(bodyItem : BodyItem, sky : Sky) {
super('四季的风', bodyItem, sky, null);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class Cloud extends EarthSkyItem {
constructor(bodyItem : BodyItem, sky : Sky) {
super('飘动的云', bodyItem, sky, null);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class Thunder extends EarthSkyItem {
constructor(bodyItem : BodyItem, sky : Sky) {
super('隆隆的雷声', bodyItem, sky, null);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class Sun extends EarthSkyItem {
constructor(bodyItem : BodyItem, sky : Sky) {
super('太阳', bodyItem, sky, null);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class Moon extends EarthSkyItem {
constructor(bodyItem : BodyItem, sky : Sky) {
super('月亮', bodyItem, sky, null);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class FourPole extends EarthSkyItem {
constructor(bodyItem : BodyItem, earth : Earth) {
super('大地上的东、西、南、北四极', bodyItem, null, earth);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class Ground extends EarthSkyItem {
constructor(bodyItem : BodyItem, earth : Earth) {
super('辽阔的大地', bodyItem, null, earth);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class Reiver extends EarthSkyItem {
constructor(bodyItem : BodyItem, earth : Earth) {
super('奔流不息的江河', bodyItem, null, earth);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class Rain extends EarthSkyItem {
constructor(bodyItem : BodyItem, earth : Earth) {
super('滋润万物的雨露', bodyItem, null, earth);
console.log(`他${bodyItem.name},变成了${this.name};`);
}
} class BodyItem extends Name {
constructor(name:string) {
super(name);
}
} class Pangu extends Name{
constructor() {
super('盘古');
this.live();
} private sky : Sky;
private earth : Earth;
private height : number = 2;
private qixi = new BodyItem('呼出的气息');
private shengyin = new BodyItem('发出的声音');
private leftEye = new BodyItem('的左眼');
private rightEye = new BodyItem('的右眼');
private sizhi = new BodyItem('四肢');
private skin = new BodyItem('肌肤');
private blood = new BodyItem('血液');
private sweat = new BodyItem('汗'); live() : void {
console.log('有个叫盘古的巨人,出生在这混沌之中。');
this.sleeping();
this.wakeup();
} sleeping() : void {
console.log('他一直睡了一万八千年。');
} wakeup() : void {
console.log('有一天,盘古突然醒了。');
} kaitian(world:World) : void {
console.log('他见周围一片漆黑,就抡起大斧头,朝眼前的黑暗猛劈过去。');
let skyEarch : [Sky, Earth] = world.died();
this.sky = skyEarch[0];
this.earth = skyEarch[1];
this.grow();
} grow() : void {
console.log('天和地分开以后,盘古怕它们还会合在一起,就头顶着天,用脚使劲蹬着地。天每天升高一丈,盘古也随着越长越高。');
this.height += 20000;
this.died();
} died() : void {
console.log('这样不知过多少年,天和地逐渐成形了,盘古也累得倒了下去。');
this.transform();
} transform() : void {
let wind : Wind = new Wind(this.qixi, this.sky);
let cloud : Cloud = new Cloud(this.qixi, this.sky);
let thunder : Thunder = new Thunder(this.shengyin, this.sky);
let sun : Sun = new Sun(this.leftEye, this.sky);
let moon : Moon = new Moon(this.rightEye, this.sky);
let fourPole : FourPole = new FourPole(this.sizhi, this.earth);
let ground : Ground = new Ground(this.skin, this.earth);
let reiver : Reiver = new Reiver(this.blood, this.earth);
let rain : Rain = new Rain(this.sweat, this.earth);
//...
}
} class World extends Name{ private status : string = '混沌'; constructor() {
super('混沌世界');
console.log('很久很久以前,天和地还没有分开,宇宙混沌一片。');
} died() : [Sky, Earth] {
console.log('只听一声巨响,混沌一片的东西渐渐分开了。');
this.status = '消失';
let skyEarch : [Sky, Earth] = [new Sky(), new Earth()];
return skyEarch;
}
} class Sky extends Name{
constructor() {
super('天');
console.log('轻而清的东西,缓缓上升,变成了天;');
}
} class Earth extends Name{
constructor() {
super('地');
console.log('重而浊的东西,慢慢下降,变成了地。');
}
} let world = new World();
let pangu = new Pangu();
pangu.kaitian(world);

  

TypeScript作业的更多相关文章

  1. CSS3与页面布局学习总结(七)——前端预处理技术(Less、Sass、CoffeeScript、TypeScript)

    CSS不像其它高级语言一样支持算术运算.变量.流程控制与面向对象特性,所以CSS样式较多时会引起一些问题,如修改复杂,冗余,某些别的语言很简单的功能实现不了等.而javascript则是一种半面向对象 ...

  2. 深入浅出 Typescript 学习笔记

    TypeScript 是 JavaScript 的一个超集,支持 ECMAScript 6 标准. TypeScript 由微软开发的自由和开源的编程语言. TypeScript 设计目标是开发大型应 ...

  3. TypeScript: Angular 2 的秘密武器(译)

    本文整理自Dan Wahlin在ng-conf上的talk.原视频地址: https://www.youtube.com/watch?v=e3djIqAGqZo 开场白 开场白主要分为三部分: 感谢了 ...

  4. TypeScript为Zepto编写LazyLoad插件

    平时项目中使用的全部是jQuery框架,但是对于做webapp来说jQuery太过于庞大,当然你可以选择jQuery 2.*针对移动端的版本. 这里我采用移动端使用率比较多的zepto框架,他跟jqu ...

  5. TypeScript Vs2013 下提示Can not compile modules unless '--module' flag is provided

    VS在开发TypeScript程序时候,如果import了模块有的时候会有如下提示: 这种情况下,只需要对当前TypeScript项目生成设置为AMD规范即可!

  6. python10作业思路及源码:类Fabric主机管理程序开发(仅供参考)

    类Fabric主机管理程序开发 一,作业要求 1, 运行程序列出主机组或者主机列表(已完成) 2,选择指定主机或主机组(已完成) 3,选择主机或主机组传送文件(上传/下载)(已完成) 4,充分使用多线 ...

  7. SQLServer2005创建定时作业任务

    SQLServer定时作业任务:即数据库自动按照定时执行的作业任务,具有周期性不需要人工干预的特点 创建步骤:(使用最高权限的账户登录--sa) 一.启动SQL Server代理(SQL Server ...

  8. TypeScript

    TypeScript: Angular 2 的秘密武器(译)   本文整理自Dan Wahlin在ng-conf上的talk.原视频地址: https://www.youtube.com/watch? ...

  9. 打造TypeScript的Visual Studio Code开发环境

    打造TypeScript的Visual Studio Code开发环境 本文转自:https://zhuanlan.zhihu.com/p/21611724 作者: 2gua TypeScript是由 ...

随机推荐

  1. 201621123049《java程序设计》第四周学习总结

    1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 继承 类型转换 覆盖 1.2 尝试使用思维导图将这些关键词组织起来.注:思维导图一般不需要出现过多的字. 2. 书面作业 1. ...

  2. ES6中Set 和 Map用法

    JS中Set与Map用法 一.Set 1.基本用法 ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set 本身是一个构造函数,用来生成 Set 数据结构. ...

  3. 【立体几何】分类讨论很细节 Gym - 101967I Путешествие по тору

    http://codeforces.com/gym/101967/attachments 题意:定义了一个甜甜圈.(torus) 不是让你二重积分啦233 现在有一个星球是甜甜圈形状的,它有四条很关键 ...

  4. DELPHI中完成端口(IOCP)的简单分析(3)

    DELPHI中完成端口(IOCP)的简单分析(3)   fxh7622关注4人评论7366人阅读2007-01-17 11:18:24   最近太忙,所以没有机会来写IOCP的后续文章.今天好不容易有 ...

  5. day5_函数返回值

    每个函数都有返回值,如果没有在函数里面指定返回值的话,在python里面函数执行完之后,默认会返回一个None,函数也可以有多个返回值,如果有多个返回值的话,会把返回值都放到一个元组中,返回的是一个元 ...

  6. Docker入门基础(一)

    Docker入门基础 Linux只存在文件目录,不存在“盘”的概念 Dockers优点:方便部署环境.资源占用少(微服务) Docker的三大概念 镜像:类似虚拟机的镜像.用俗话说就是安装文件.容器: ...

  7. Redis入门到高可用(十九)——Redis Sentinel

    一.Redis  Sentinel架构     二.redis sentinel安装与配置 四.客户端连接Sentinel            四.实现原理—— 故障转移演练(客户端高可用) 五.实 ...

  8. RabbitMQ:Docker环境下搭建rabbitmq集群

    RabbitMQ作为专业级消息队列:如何在微服务框架下搭建 使用组件 文档: https://github.com/bijukunjummen/docker-rabbitmq-cluster 下载镜像 ...

  9. 经验分享 | 如何拿到自己满意的offer?

    本文阅读时间约16分钟 最近两年,人工智能(AI)就像一个点石成金的神器,所有的行业,创业公司,或是求职,只要沾着这个词,多少有点脚踩五彩祥云的感觉,故事来了,融资来了,高薪来了. 于是,越来越多的人 ...

  10. 实验一:C++简单程序设计

    [实验一] #2-28 实现一个简单的菜单程序,运行时显示“Menu:A(dd) D(elete) S(ort) Q(uit),Selete one:”提示用户输入.A表示增加,D表示删除,S表示排序 ...