好的,我正在制作HiLo游戏,但发现代码有问题。玩家以1000点开始,但是他们可以下高于其点数的下注。我想要它,所以他们不能比他们所拥有的更多赌注
int playerPoints = 1000;
int betPoints;
int predict;
int randomNumber;
System.out.println("Enter the points you want to risk");
betPoints = input.nextInt();
我需要betPoints小于或等于playerPoints。如何限制整数以遵守该规定?
答案 0 :(得分:2)
以Allocatable:
cpu: 940m
ephemeral-storage: 47093746742
hugepages-2Mi: 0
memory: 2702216Ki
pods: 110
Non-terminated Pods: (7 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits
--------- ---- ------------ ---------- --------------- -------------
default mission-worker-5cf6654687-fwmk4 100m (10%) 0 (0%) 0 (0%) 0 (0%)
default mission-worker-5cf6654687-lnwkt 100m (10%) 0 (0%) 0 (0%) 0 (0%)
kube-system fluentd-gcp-v3.1.1-5b6km 100m (10%) 1 (106%) 200Mi (7%) 500Mi (18%)
kube-system kube-dns-76dbb796c5-jgljr 260m (27%) 0 (0%) 110Mi (4%) 170Mi (6%)
kube-system kube-proxy-gke-test-cluster-pool-1-96c6d8b2-m15p 100m (10%) 0 (0%) 0 (0%) 0 (0%)
kube-system metadata-agent-nb4dp 40m (4%) 0 (0%) 50Mi (1%) 0 (0%)
kube-system prometheus-to-sd-gwlkv 1m (0%) 3m (0%) 20Mi (0%) 20Mi (0%)
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 701m (74%) 1003m (106%)
memory 380Mi (14%) 690Mi (26%)
Events: <none>
为例:
Math.min()
答案 1 :(得分:0)
更改betPoints = input.nextInt();
,
do {
betPoints = input.nextInt();
} while(betPoints > playerPoints);