2016年9月19日
TypeScript制作天天菜谱
摘要: 还在因为每天做什么菜发愁么?还在因为买什么菜吃啥都不知道感到困惑么?今天来分享一个用TS制作的天天菜单 来解决问题
由于公司饭总总提议,不知道每天吃什么,买什么菜,感到发愁,于是乎神奇的程序员想了一个办法,用TS写了一个天天菜谱,从此以后饭总姐姐再也不用担心吃什么发愁了,直接上代码
var People = {
soup : ["炸酱面","海带汤","玉米汤","疙瘩汤",
"排骨汤","菠菜汤","萝卜汤","西红柿鸡蛋汤",
"牛肉萝卜汤","紫菜蛋花汤","炒饼", "炒面",
"大骨汤","猪肚包鸡汤"
],//汤
vegetable : ["酸辣土豆丝","腐竹炒辣椒", "干瘪豆角","拉皮凉拌",
"拉皮凉拌","酸辣豆芽", "黑木耳炒肉丝","虾米剁椒炒鸡蛋",
"c炒鸡蛋","酸辣大白菜", "酸菜粉","千叶豆腐",
"葱香豆腐丝","松仁玉米","地三鲜","生菜凉拌百叶粉丝",
"土豆泥","炒豆芽","烧茄子","胶白"
],//蔬菜
meats :["肉炒黄瓜","肉炒鸡蛋","西葫芦炒肉","白菜炒肉",
"茄子炒肉","辣子鸡丁","炸鸡柳","红油鸡丝",
"蟹黄豆腐","小炒肝尖","猪儿朵香菜黄瓜"
],//小肉
meat : ["可乐鸡翅","猪肉炖","土豆炖芸豆排骨", "锅包肉",
"糖醋排骨","猪肉炖粉条","猪肉炖酸菜","京酱肉丝",
"红烧肉","毛血旺"
],//大肉
getName: function(){
return()=>{
var j = Math.floor(Math.random()*11);//大肉
var q = Math.floor(Math.random()*10);//小肉
var v = Math.floor(Math.random()*20);//素菜
var i = Math.floor(Math.random()*14);//汤
return {
m: this.meats[j],//肉类
n: this.meat[q],//肉类
s: this.soup[i],//汤
t: this.vegetable[v],//蔬菜
}
}
}
}
var myName = People.getName();
alert("今天吃的大肉菜是 " + myName().n +" 小肉菜是 "+ myName().m + " 素菜是 " +myName().t +" 汤类是 "+ myName().s );
天天菜单
大菜11道,小肉菜10道,素菜20道,汤14样,整体运行效果是不错的,也是刚刚接触TS,随手写了一个小玩意,不喜欢的不要喷就好 哈哈哈哈~~ 今天又是代码满满的一天