当我尝试创建一个公共布尔值时,它会给我错误
对于参数类型Boolean,Float,运算符&&未定义
代码是:
public boolean mouseHover(int mouseX, int mouseY, float x, float y, float height, float width){
if(((mouseX >= x) && (x + width) && (mouseY >= y) && (mouseY <= y + height))){
return true;
}else{
return false;
}
Run Code Online (Sandbox Code Playgroud) 请注意我可以使用的好奇心(代码示例见第38行(代码编辑))
Boolean bol = true;
Boolean bol1 = !bol;
Run Code Online (Sandbox Code Playgroud)
我的问题是
我正在尝试评估一个字符:
bool repeat = true;
while (repeat)
//code
char x;
cout << "Would you like to tansfer another file? Y/N ";
cin >> x;
if (x == 'y' || x == 'Y')
repeat = true;
if (x == 'n' || x == 'N')
repeat = false;
else
throw "Input error";
Run Code Online (Sandbox Code Playgroud)
我一直得到输入错误作为我的控制台输出.有什么想法吗?我不能让while循环重复.
所以我需要将输入文本中的某些字母与'z'交换但由于某种原因我的检查不起作用.这是代码:
bool CheckLetter(int x) {
if(nm[0][x] == 'a' || 'e' || 'i' || 'o')return true;
return false; }
Run Code Online (Sandbox Code Playgroud)
问题在于'||'.如果我只保留'a',我的程序就能完美运行.通过这种方式它只给我这样的东西:'zzzzzz'.有任何想法吗?
def main():
num = int(input('Please enter an odd number: '))
if False:
print('That was not a odd number, please try again.')
else:
print('Congrats, you know your numbers!')
def number():
if (num / 2) == 0:
return True,num
else:
return False,num
main()
Run Code Online (Sandbox Code Playgroud)
我试图这样做,如果输入的数字是奇数,它祝贺用户.如果没有,那么它应该告诉他们再试一次.我试图将布尔值返回到main,然后当我尝试使用main函数中的代码来提示用户时,它不起作用.
我正在创建一个图书档案计划,其中一位数据成员说这本书是否被阅读.但是我不能让程序在屏幕上写"是",所以我猜它永远不会改变,即使我在被问及是否读过这本书时也会说'Y'.谁能看到我做错了什么?
cout << "\n\tEnter title of book: ";
cin >> title;
cout << "\tEnter author of book: ";
cin >> author;
cout << "\tEnter genre of book (1. Crime, 2. Sports, 3. Science, 4. Drama): ";
cin >> choice;
switch(choice)
{
case 1: genre = crime; break;
case 2: genre = sports; break;
case 3: genre = science; break;
case 4: genre = drama; break;
}
cout << "\tEnter year of publication: ";
cin >> yearPublished;
cout << "\tHave you …Run Code Online (Sandbox Code Playgroud) 我试图做出类似的东西:
// int counter; - this is changing in ther other parts of program
bool abc1; bool abc2; bool abc3; bool abc4;
if("abc" + counter == true)
{
//some code
}
Run Code Online (Sandbox Code Playgroud)
无论如何,我需要将string和int转换为bool名称.我怎样才能做到这一点?
我正在开发一些东西.但是出现错误,我无法修复它.它说''运算符 - =未定义参数类型(s)double,boolean''在我的代码中:
if (x -= 15.0D < 0.0D) {
Run Code Online (Sandbox Code Playgroud)
我只是遗漏了部分代码.任何人都知道如何解决它?我无法让它发挥作用.谢谢 :)
11 % 14 == 11 and ( 6 * 3 // 4 > 4 or 20 // 6 != 3)
Run Code Online (Sandbox Code Playgroud)
当我在Python中键入它时,它告诉我该语句是错误的.
if 11 % 14 == 11 and ( 6 * 3 // 4 > 4 or 20 // 6 != 3):
print("True")
else:
print("False")
Run Code Online (Sandbox Code Playgroud)
从我的理解11%14 == 11是真的,6*3 = 18 // 4是4所以这是真的,20 // 6将是3所以这也应该是真的吗?有人可以向我解释它是如何错误的吗?
当实现棋盘游戏时,棋盘格可以处于三种可能的可用状态之一:True(第一玩家占用的小区),False(第二玩家占用的小区)或None(小区为空).
我的问题是:
为什么
not(True) == None
return True
Run Code Online (Sandbox Code Playgroud)
而实际上应该return False呢?
为什么呢
not(False) == None
return True
Run Code Online (Sandbox Code Playgroud)
而实际上应该return False呢?
这可能是Python中可能的错误,应该尽快向开发人员报告,其中包括其中的开发人员?
python boolean-logic boolean boolean-expression boolean-operations
boolean ×10
c++ ×3
java ×3
python ×3
c# ×1
double ×1
if-statement ×1
return-value ×1
string ×1
while-loop ×1