小编arv*_*yon的帖子

自定义货币系统乘法

我还在学习,所以放轻松。

我有以下货币系统:

3 种不同的硬币,我们称它们为玫瑰红(红色)、达拉宁(金色)和熟食(灰色)。100 Delis 等于 1 Daranen,100 Daranen 等于 1 Rhodonite。玫瑰石没有限制。

所以我试图将该货币乘以双倍系数。这是我的功能:

    public static Price multiply(Price price, double factor) {
       int de = (int)Math.round(price.getDelis() * factor);
       int da = (int)Math.round(price.getDaranen() * factor);
       int r = (int)Math.round(price.getRhodoniten() * factor);
       if ((de / 100) >= 1) {
           de = de % 100;
           da += de / 100;
       }
       if ((da / 100) >= 1) {
           da = da % 100;
           r += da / 100;
       }
       return new Price(r, da, de); …
Run Code Online (Sandbox Code Playgroud)

java multiplication modulo

1
推荐指数
1
解决办法
53
查看次数

标签 统计

java ×1

modulo ×1

multiplication ×1