摘要: 1 //singleton 单例模式 2 3 import console; 4 5 import thread; 6 class singleton{ 7 ctor(){}; 8 instance; 9 10 test = function(){ 11 return "对象"; 12 } 13 1 阅读全文
posted @ 2024-05-26 18:40 Axuanup 阅读(13) 评论(0) 推荐(0) 编辑
摘要: //Car 实现封装继承多态 import console //父类 class Car{ ctor(make, model, color, year) {//构造函数,用于初始化对象的属性 this.make = make //制造商 this.model = model //型号 this.co 阅读全文
posted @ 2024-05-26 18:40 Axuanup 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 1 //calculate 简单工厂模式 2 3 //简单工厂模式 4 import console; 5 6 //运算类 7 class operation{ 8 ctor(){}; 9 numberA = 0; 10 numberB = 0; 11 getResult = function(){ 阅读全文
posted @ 2024-05-26 18:39 Axuanup 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 1 //queue队列结构 2 //队列的特点:先进先出 3 import console; 4 class queueEx{ 5 ctor(){ 6 this.items = {} 7 }; 8 //排队 9 入队 = function(element){ 10 ..table.push(this 阅读全文
posted @ 2024-05-26 18:29 Axuanup 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 1 --普通表 2 local tab = {1,2,3} 3 4 --元表 5 local meta = { 6 insert = function(t,v) 7 --监测表增加成员 8 print("增加一个值",v) 9 table.insert(t,v) 10 end, 11 remove 阅读全文
posted @ 2024-05-26 18:18 Axuanup 阅读(2) 评论(0) 推荐(0) 编辑