在printme函数中,将所有false设置为true

时间:2018-07-21 00:05:28

标签: c++

我正在创建一个简单的汽车创造者游戏,以练习诸如继承和类之类的事情。我为此感到难过。当我调试时,它说值是应该的,但随后转到printme函数,无论如何都将它们设置为true。

import React from "react";
import ReactDOM from "react-dom";

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      handleChange: e => {
        e.preventDefault();
        console.log("this.state.handleChange");
      }
    };
  }

  handleChange = e => {
    e.preventDefault();
    console.log("this.handleChange");
  };

  render() {
    return (
      <div className="App">
        <h1>Hello CodeSandbox</h1>
        <button onClick={this.handleChange}>this.handleChange</button>
        <button onClick={this.state.handleChange}>
          this.state.handleChange
        </button>
      </div>
    );
  }
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

这是打印功能

cout << "Does your car have stripes?" << endl;
bool validInput8; // stops from sending code all of the place and mixing cars
string inputStripes;
inputStripes = lower(inputStripes);
do
{
cin >> inputStripes;
    inputStripes = lower(inputStripes);

    if (inputStripes == "yes")
    {
        sportscar.Stripes = true;
        validInput8 = true;

    }
    else if (inputStripes == "no")
    {
        sportscar.Stripes = false;
        validInput8 = true;
    }
    else
    {
        cout << "Your input is not valid. Please enter yes or no!" << endl;
        cin.get();
        validInput8 = false;
    }
} while (!validInput8);
Continue();
cin.get();
clear();
sportscar.PrintCarDetails(); 

1 个答案:

答案 0 :(得分:1)

您在IF语句上使用一个=,而不是两个。对于其中一个,您只是分配值,而不检查它是否确实为真。