-
Notifications
You must be signed in to change notification settings - Fork 33
/
百万跑商计算器.js
308 lines (233 loc) · 12.3 KB
/
百万跑商计算器.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
// 原代码来自 https://www.bilibili.com/video/BV1EM4y1V7TB, 已获得许可
// //@ts-check
// class 文府别院 {
// #buying_price;
// #selling_price;
// constructor() { };
// getbuying_price() {
// return this.#buying_price;
// };
// getselling_price() {
// return this.#selling_price;
// };
// getvalue() {
// this.#buying_price = parseInt(console.rawInput("请输入玉买价:"));
// console.log("玉买价:" + this.#buying_price);
// this.#selling_price = parseInt(console.rawInput("请输入流云卖价:"));
// console.log("流云卖价:" + this.#selling_price);
// };
// }
// class 全氏山庄 extends 文府别院 {
// #buying_price;
// #buying_num;
// #selling_price;
// #selling_num;
// #empty_blank;
// #money_in_pack;
// constructor(bp, sp, eb, mip) {
// super();
// this.#buying_price = bp;
// this.#selling_price = sp;
// this.#empty_blank = eb;
// this.#money_in_pack = mip;
// }
// getvalue() {
// this.#money_in_pack = parseInt(console.rawInput("请输入包里已有宝钞:"));
// console.log("包里已有宝钞:" + this.#money_in_pack);
// this.#empty_blank = parseInt(console.rawInput("请输入空格子个数:"));
// console.log("空格子个数:" + this.#empty_blank);
// this.#selling_price = parseInt(console.rawInput("请输入玉卖价:"));
// console.log("玉卖价:" + this.#selling_price);
// this.#buying_price = parseInt(console.rawInput("请输入流云买价:"));
// console.log("流云买价:" + this.#buying_price);
// }
// empty_gaining(w) {
// return 2 * this.#empty_blank * (0 - this.#buying_price + w.getselling_price() - w.getbuying_price())
// }
// transfer_gaining(w) {
// return this.#selling_price - this.#buying_price + w.getselling_price() - w.getbuying_price();
// }
// transfer_num(w) {
// let temp = Math.floor((190000 - this.#money_in_pack - this.empty_gaining(w)) / this.transfer_gaining(w));
// if (temp % 2 == 0) return temp;
// else {
// this.#money_in_pack += this.#selling_price - w.getbuying_price();
// return temp;
// }
// }
// real_num(w, tn) {
// let temp = tn;
// if (this.#money_in_pack + this.empty_gaining(w) + temp * this.transfer_gaining(w) + 2 * w.getbuying_price() > 200000) return temp - 1;
// else return temp;
// }
// }
// function main() {
// console.show();
// let q = new 全氏山庄(5500, 8000, 6, 100000);
// let w = new 文府别院();
// q.getvalue();
// w.getvalue();
// q.empty_gaining(w);
// console.log("每个空可以获得: " + q.empty_gaining(w));
// q.transfer_gaining(w);
// console.log("倒单个流云可以获得: " + q.transfer_gaining(w));
// let tn = Math.floor(q.transfer_num(w));
// console.log("理想倒的次数是: " + tn);
// console.log("应该倒的次数是: " + q.real_num(w, tn));
// return 0;
// }
// main();
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
var _buying_price = /*#__PURE__*/new WeakMap();
var _selling_price = /*#__PURE__*/new WeakMap();
//@ts-check
var 文府别院 = /*#__PURE__*/function () {
"use strict";
function 文府别院() {
_classCallCheck(this, 文府别院);
_buying_price.set(this, {
writable: true,
value: void 0
});
_selling_price.set(this, {
writable: true,
value: void 0
});
}
_createClass(文府别院, [{
key: "getbuying_price",
value: function getbuying_price() {
return _classPrivateFieldGet(this, _buying_price);
}
}, {
key: "getselling_price",
value: function getselling_price() {
return _classPrivateFieldGet(this, _selling_price);
}
}, {
key: "getvalue",
value: function getvalue() {
_classPrivateFieldSet(this, _buying_price, parseInt(console.rawInput("请输入玉买价:")));
console.log("玉买价:" + _classPrivateFieldGet(this, _buying_price));
_classPrivateFieldSet(this, _selling_price, parseInt(console.rawInput("请输入流云卖价:")));
console.log("流云卖价:" + _classPrivateFieldGet(this, _selling_price));
}
}]);
return 文府别院;
}();
var _buying_price2 = /*#__PURE__*/new WeakMap();
var _buying_num = /*#__PURE__*/new WeakMap();
var _selling_price2 = /*#__PURE__*/new WeakMap();
var _selling_num = /*#__PURE__*/new WeakMap();
var _empty_blank = /*#__PURE__*/new WeakMap();
var _money_in_pack = /*#__PURE__*/new WeakMap();
var 全氏山庄 = /*#__PURE__*/function (_文府别院) {
"use strict";
_inherits(全氏山庄, _文府别院);
var _super = _createSuper(全氏山庄);
function 全氏山庄(bp, sp, eb, mip) {
var _this;
_classCallCheck(this, 全氏山庄);
_this = _super.call(this);
_buying_price2.set(_assertThisInitialized(_this), {
writable: true,
value: void 0
});
_buying_num.set(_assertThisInitialized(_this), {
writable: true,
value: void 0
});
_selling_price2.set(_assertThisInitialized(_this), {
writable: true,
value: void 0
});
_selling_num.set(_assertThisInitialized(_this), {
writable: true,
value: void 0
});
_empty_blank.set(_assertThisInitialized(_this), {
writable: true,
value: void 0
});
_money_in_pack.set(_assertThisInitialized(_this), {
writable: true,
value: void 0
});
_classPrivateFieldSet(_assertThisInitialized(_this), _buying_price2, bp);
_classPrivateFieldSet(_assertThisInitialized(_this), _selling_price2, sp);
_classPrivateFieldSet(_assertThisInitialized(_this), _empty_blank, eb);
_classPrivateFieldSet(_assertThisInitialized(_this), _money_in_pack, mip);
return _this;
}
_createClass(全氏山庄, [{
key: "getvalue",
value: function getvalue() {
_classPrivateFieldSet(this, _money_in_pack, parseInt(console.rawInput("请输入包里已有宝钞:")));
console.log("包里已有宝钞:" + _classPrivateFieldGet(this, _money_in_pack));
_classPrivateFieldSet(this, _empty_blank, parseInt(console.rawInput("请输入空格子个数:")));
console.log("空格子个数:" + _classPrivateFieldGet(this, _empty_blank));
_classPrivateFieldSet(this, _selling_price2, parseInt(console.rawInput("请输入玉卖价:")));
console.log("玉卖价:" + _classPrivateFieldGet(this, _selling_price2));
_classPrivateFieldSet(this, _buying_price2, parseInt(console.rawInput("请输入流云买价:")));
console.log("流云买价:" + _classPrivateFieldGet(this, _buying_price2));
}
}, {
key: "empty_gaining",
value: function empty_gaining(w) {
return 2 * _classPrivateFieldGet(this, _empty_blank) * (0 - _classPrivateFieldGet(this, _buying_price2) + w.getselling_price() - w.getbuying_price());
}
}, {
key: "transfer_gaining",
value: function transfer_gaining(w) {
return _classPrivateFieldGet(this, _selling_price2) - _classPrivateFieldGet(this, _buying_price2) + w.getselling_price() - w.getbuying_price();
}
}, {
key: "transfer_num",
value: function transfer_num(w) {
var temp = Math.floor((190000 - _classPrivateFieldGet(this, _money_in_pack) - this.empty_gaining(w)) / this.transfer_gaining(w));
if (temp % 2 == 0) return temp;else {
_classPrivateFieldSet(this, _money_in_pack, _classPrivateFieldGet(this, _money_in_pack) + (_classPrivateFieldGet(this, _selling_price2) - w.getbuying_price()));
return temp;
}
}
}, {
key: "real_num",
value: function real_num(w, tn) {
var temp = tn;
if (_classPrivateFieldGet(this, _money_in_pack) + this.empty_gaining(w) + temp * this.transfer_gaining(w) + 2 * w.getbuying_price() > 200000) return temp - 1;else return temp;
}
}]);
return 全氏山庄;
}(文府别院);
function main() {
console.show();
var q = new 全氏山庄(5500, 8000, 6, 100000);
var w = new 文府别院();
var mip;
q.getvalue();
w.getvalue();
q.empty_gaining(w);
console.log("每个空可以获得: " + q.empty_gaining(w));
q.transfer_gaining(w);
console.log("倒单个流云可以获得: " + q.transfer_gaining(w));
var tn = Math.floor(q.transfer_num(w));
console.log("理想倒的次数是: " + tn);
console.log("应该倒的次数是: " + q.real_num(w, tn));
return 0;
}
main();