地图格子 java_包含另一个地图的java8 genrate地图

如何使用Java=8实现这一点

我有一个以下格式的csv,从中我想填充地图

外部地图将在哪里有键

scriptId

transationType

因为这些是独特的

Type

和内部地图

斯克里蒂德

键应该包含前5个值,从位置2开始声明为键,从3开始声明为值。

>

>

csv文件内容

Type,ArcesiumValue,GICValue

scriptId,TATA,TATA Moters

scriptId,REL,Reliance Industries Ltd

scriptId,LNT,L&T

scriptId,SBI,State Bank of India

transactionType,P,B

transactionType,S,S

我如何使用java8生成这个

public void loadReferenceData() throws IOException {

List>> cache = Files.lines(Paths.get("data/referenceDataMapping.csv")).skip(1)

.map(mapRefereneData).collect(Collectors.toList());

System.out.println(cache);

}

public static Function>> mapRefereneData = (line) -> {

String[] sp = line.split(",");

Map> cache = new HashMap>();

try {

if (cache.containsKey(sp[0])) {

cache.get(sp[0]).put(sp[1], sp[2]);

} else {

Map map = new HashMap();

map.put(sp[1], sp[2]);

cache.put(sp[0], map);

}

} catch (NumberFormatException e) {

e.printStackTrace();

}

return cache;

};

解释下面代码 game.ready = { startX: 41.5, startY: 21.5, width: game.cellWidth * 3, height: game.cellWidth, bubbles: [], init: function () { this.genrate(); var me = this; me.flyin(); }, genrate: function () { for (var i = 0; i < 3; i++) { var color = game.colors[game.getRandom(game.mode)]; this.bubbles.push(new Bubble(i, 0, color)); } //console.log(this.bubbles); }, draw: function () { var ctx = game.ctx; ctx.save(); ctx.translate(this.startX, this.startY); ctx.beginPath(); ctx.strokeStyle = "#555"; ctx.strokeRect(0, 0, this.width, this.height); ctx.stroke(); //绘制准备的泡 this.bubbles.forEach(function (bubble) { bubble.draw(); }); ctx.restore(); }, isMoving: false, flyin: function () { var emptys = game.map.getEmptyBubbles(); if (emptys.length < 3) { //GAME OVER game.over(); return; } var me = this; var status = [0, 0, 0]; var times = 1; game.play("flyin", function () { if (status[0] && status[1] && status[2]) { game.stop("flyin"); me.isMoving = false; status = [0, 0, 0]; me.bubbles = []; me.genrate(); return; } me.isMoving = true; for (var i = 0; i < me.bubbles.length; i++) { if (status[i]) { continue; } var target = emptys[i]; var x2 = target.px + game.map.startX - me.startX; var y2 = target.py + game.map.startY - me.startY; var current = me.bubbles[i]; var step = Math.abs(x2 - current.px)/10 || Math.abs(y2 - current.y)/10; if (current.px < x2) { current.py = ((y2 - current.py) / (x2 - current.px)) * step + current.py; current.px += step; if (current.px > x2) { current.px = x2; } } else if (current.px > x2) { current.py = ((y2 - current.py) / (current.px - x2)) * step + current.py; current.px -= step; if (current.px < x2) { current.px = x2; } } else { current.py += step; } if (current.py > y2) { current.py = y2; } if (parseInt(current.px+0.1) == x2 && parseInt(current.py+0.1) == y2) { status[i] = 1; current.x = target.x; current.y = target.y; game.map.addBubble(current); game.map.clearLine(current.x, current.y, current.color, false); } } }, 10); } };
最新发布
06-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值