From d7cbe984b51fb8fa509890809aa75e6416168249 Mon Sep 17 00:00:00 2001 From: ZY <zc857179121@qq.com> Date: 星期一, 19 八月 2024 08:20:49 +0800 Subject: [PATCH] 1 --- src/main/java/com/zy/common/model/Shelves.java | 42 ++++++++++++++++++++++++++++++------------ 1 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/zy/common/model/Shelves.java b/src/main/java/com/zy/common/model/Shelves.java index 17515ce..ae5015f 100644 --- a/src/main/java/com/zy/common/model/Shelves.java +++ b/src/main/java/com/zy/common/model/Shelves.java @@ -1,5 +1,9 @@ package com.zy.common.model; +import com.alibaba.fastjson.JSON; +import com.core.common.Arith; +import com.core.exception.CoolException; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -11,13 +15,13 @@ public class Shelves { // 璐ф灦鎺掓暟閲� - private final int size; + public final int size; // 璐ф灦缁勬暟閲� - private final int group; + public final int group; // 鍋忕Щ閲廩default:0] - private final int offset; + public final int offset; // 璐ф灦瀹炰緥鑺傜偣闆嗗悎 public List<List<Integer>> nodes; @@ -34,9 +38,11 @@ public Shelves(int size, int group, int offset) { this.size = size; this.group = group; - this.offset = offset; + this.offset = offset-1; init(); } + + /** * 鍒濆鍖栨柟娉曘�愮鏈夈�� @@ -97,16 +103,28 @@ return -1; } + public Integer get(Integer curRow) { + for (List<Integer> node : nodes){ + if (node.contains(curRow)) { + return nodes.indexOf(node) + 1; + } + } + throw new CoolException("璐ф帓妫�绱㈢郴缁熸姤閿欙紝 node:" + JSON.toJSONString(nodes) + ", curRow:" + curRow); + } public static void main(String[] args) throws InterruptedException { - Shelves shelves = new Shelves(8,2); - System.out.println(shelves.nodes.toString()); - int start = 1; - while (true) { - System.out.println(start); - start = shelves.start(start); - Thread.sleep(500L); - } + + double remainder = Arith.divides(1,16 - 1, 16); + System.out.println(remainder); + System.out.println((int) remainder); +// Shelves shelves = new Shelves(8,2); +// System.out.println(shelves.nodes.toString()); +// int start = 1; +// while (true) { +// System.out.println(start); +// start = shelves.start(start); +// Thread.sleep(500L); +// } } } -- Gitblit v1.9.1