#(nimsy) c++ hw assignment (drawing circles and rectangles in pgm files)

24 messages · Page 1 of 1 (latest)

bronze zinc
#

yo

dreamy obsidianBOT
#

(nimsy) c++ hw assignment (drawing circles and rectangles in pgm files)

dreamy obsidianBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

bronze zinc
#

for some reason, this is wrong?

#
        if (shape != "rect" || shape != "circle") {
            cout << "Invalid shape specified! Try again.\n";
            continue;
        }
#

even if i type the words "rect" or "circle" it works

#

but if i remove the ||, it works fine individually and idk why

#
#include <iostream>
using namespace std;

const int IMG_WIDTH = 800;

typedef uint8_t byte;

enum Coordinate { X, Y };

struct Color {
    int foreground = 255;
    int background = 0;
};

//main
int main() {


    string shape;
    string filename;

    while (true) {

        cout << "Enter a shape (or 'q' to exit)." <<
            "\nOptions: circle, rect" <<
            "\nInput: ";

        cin >> shape;

        if (shape == "q") {
            cout << "Exiting program.";
            break;
        }

        if (shape != "rect" || shape != "circle") {
            cout << "Invalid shape specified! Try again.\n";
            continue;
        }

        cout << "Enter filename or leave blank for default." <<
            "\nInput: ";

        cin >> filename;

        if (filename == "") {
            filename = shape;
        }

//        std::cout << "your input was " << filename << "\n";
    }

    return 0;

}
#

this is what i have rn

bronze zinc
#

lol

#

i just found another student trying to figure this out on stack overflow 😂

bronze zinc
#

also

#

ive been looking all over to find out how to detect when the player inputs just enter

#

since im trying to do this ```c++

    cout << "Enter filename or leave blank for default." <<
        "\nInput: ";
    cin >> filename;
bronze zinc
#

i finished the entire assignment, just back to the last issue i posted

#

and as for the first problem, i simply had to use and/&& instead of or/||

#

all good, i just ended up not doing enter, hopefully i dont lose points