gpt4 book ai didi

java - <= && >= Java/Android 运算符

转载 作者:太空狗 更新时间:2023-10-29 16:21:07 25 4
gpt4 key购买 nike

我在这段代码上遇到了问题。它总是继续“你在博物馆外面或再次检查你的位置” toast :/你认为问题是什么?这是代码:

    x3 = x3 * -1; //for example is 187
y3 = y3 * -1;//for example is 698

ImageView img = (ImageView) findViewById(R.id.imageView1);

if(((x3 <= 150) && (x3 >= 170)) && ((y3 <= 680) && (y3 >= 725))){
img.setImageResource(R.drawable.map_1_full_lite);
Toast.makeText(getBaseContext(), "You're currently on Section 1", Toast.LENGTH_LONG).show();
currentSection = "sect_1";
}else if(((x3 <= 170) && (x3 >= 195)) && ((y3 <= 690) && (y3 >= 715))){
img.setImageResource(R.drawable.map_2_full_lite);
Toast.makeText(getBaseContext(), "You're currently on Section 2", Toast.LENGTH_LONG).show(); //this suppost to be the output
currentSection = "sect_2";
}else if(((x3 <= 200) && (x3 >= 230)) && ((y3 <= 680) && (y3 >= 720))){
img.setImageResource(R.drawable.map_3_full_lite);
Toast.makeText(getBaseContext(), "You're currently on Section 3", Toast.LENGTH_LONG).show();
currentSection = "sect_3";
}else if(((x3 <= 190) && (x3 >= 220)) && ((y3 <= 675) && (y3 >= 710))){
img.setImageResource(R.drawable.map_4_full_lite);
Toast.makeText(getBaseContext(), "You're currently on Section 4", Toast.LENGTH_LONG).show();
currentSection = "sect_4";
}else if(((x3 <= 175) && (x3 >= 219)) && ((y3 <= 710) && (y3 >= 745))){
img.setImageResource(R.drawable.map_5_full_lite);
Toast.makeText(getBaseContext(), "You're currently on Section 5", Toast.LENGTH_LONG).show();
currentSection = "sect_5";
}else if(((x3 <= 155) && (x3 >= 165)) && ((y3 <= 715) && (y3 >= 735))){
img.setImageResource(R.drawable.map_6_full_lite);
Toast.makeText(getBaseContext(), "You're currently on Section 6", Toast.LENGTH_LONG).show();
currentSection = "sect_6";
}else{
Toast.makeText(getBaseContext(), "You're outside of the museum or Check your postion again", Toast.LENGTH_LONG).show();
}

最佳答案

这是不可能的

(x3 <= 150) && (x3 >= 170)

原样

(x3 <= 170) && (x3 >= 195)

x3 不能小于或等于 150 且大于或等于 170。我怀疑你是故意这样的

(150 <= x3) && (x3 <= 170)

(170 <= x3) && (x3 <= 195)

关于java - <= && >= Java/Android 运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14558328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com