Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fcuk yuo, im a plant

Name: Anonymous 2008-03-28 18:48

Sup, /prog/, this is my code.

If you can make it smaller and more efficient, whilst doing the same tasks, I will award you with some Internet points.


#include <iostream>
#include <string>
#include <math.h>

class Shape {
protected:
    double height, width;
public:
    virtual void set_values() = 0;
    virtual double area() = 0;
    virtual double perimeter() = 0;
    void printarea()
    { std::cout << "\nThe area is " << this->area() << " squared.\n"; }
    virtual void printperim() = 0;
};

class Triangle: public Shape {
public:
    double area()
    {
    return height * width / 2; }
    double perimeter() {
        double z = ((width * width) - ((height / 2) * (height / 2)));
        z = sqrt(z);
        return z + z + height;
    }
    void printperim() {
        std::cout << "\nThe perimeter is " << this->perimeter() << ".\n";
    }
   
    void set_values() {
        std::cout << "Please enter the height: ";
         std::cin >> height;
         std::cout << "And the width: ";
    std::cin >> width;
    }
};

class Rectangle: public Shape {
public:
    double area()
    {
    return height * width; }
    double perimeter() {
        return (height * 2) + (width * 2);
    }
    void printperim() {
        std::cout << "The perimeter is " << this->perimeter() << ".\n";
    }
    void set_values() {
        std::cout << "Please enter the height: ";
         std::cin >> height;
         std::cout << "And the width: ";
    std::cin >> width;
    }
};

class Circle: public Shape {
public:
    double area()
    {
    return height * height * 3.14159265; }
    double perimeter() {
        return (height * 2) * 3.14159265; }
    void printperim() {
        std::cout << "The circumfrence is " << this->perimeter() << ".\n";
    }
    void set_values() {
        std::cout << "Please enter the radius: ";
        std::cin >> height; }
};

int main() {
    std::string Input;
    while(true) {
        std::cout << "Please choose a shape (Type it in, then press enter)\n  Rectangle\n  Triangle\n  Circle\n  Exit (To close program)\n";
        std::getline(std::cin, Input);
        if(Input == "Rectangle" || Input == "rectangle" || Input == "RECTANGLE") {
            Shape* rect = new Rectangle;
            std::cout << "\nDo you want to find the\n Area\n Perimeter\n";
            std::getline(std::cin, Input);
            if(Input == "Area" || Input == "AREA" || Input == "area") {
            rect->set_values();
            rect->printarea();
            delete rect;
            std::cin.ignore();
            }
            else if(Input== "Perimeter" || Input == "PERIMETER" || Input == "perimeter") {
                rect->set_values();
                rect->printperim();
                delete rect;
                std::cin.ignore();
            }
            else { std::cout << "\n\nWrong Input Received."; delete rect; }
        }
        else if(Input == "Triangle" || Input == "triangle" || Input == "TRIANGLE") {
            Shape* tri = new Triangle;
            std::cout << "\nDo you want to find\n Area\n Perimeter\n";
            std::getline(std::cin, Input);
            if(Input == "Area" || Input == "area" || Input == "AREA") {
            tri->set_values();
            tri->printarea();
            delete tri;
            std::cin.ignore();
            }
            else if(Input == "Perimeter" || Input == "Perimeter" || Input == "PERIMETER") {
                tri->set_values();
                tri->printperim();
                delete tri;
                std::cin.ignore();
            }
            else { std::cout << "\n\nWrong Input Received."; delete tri; }
        }
        else if(Input == "Circle" || Input == "circle" || Input == "CIRCLE") {
            Shape* circ = new Circle;
            std::cout << "\nDo you want to find the\n Area\n Circumfrence\n";
            std::getline(std::cin, Input);
            if(Input == "Area" || Input == "area" || Input == "AREA") {
            circ->set_values();
            circ->printarea();
            delete circ;
            std::cin.ignore();
            }
            else if(Input == "Circumfrence" || Input == "circumfrence" || Input == "CIRCUMFRENCE") {
                circ->set_values();
                circ->printperim();
                delete circ;
                std::cin.ignore();
            }
            else { std::cout << "\n\nWrong Input Received."; delete circ; }
        }
        else if(Input == "Exit" || Input == "exit" || Input == "EXIT") {
            exit(0);
        }
        else std::cout << "\nWrong input received. \nPlease make sure you spelt the word correctly and used capitals.";
    std::cout << "\n\n\n         Press <Enter> to continue.";
    std::cin.get();
    system("CLS");
    }
    return 0;
}

Name: Anonymous 2008-03-28 18:50

system("CLS");
failure

Name: Anonymous 2008-03-28 18:52

Shitty code is shitty

Name: Anonymous 2008-03-28 18:57

>>3
back to /b/, please.

Name: Anonymous 2008-03-28 19:02

hi

Name: Anonymous 2008-03-28 19:03

>>4
What's your point?

Name: Anonymous 2008-03-28 19:25

>>6

Name: Anonymous 2008-03-28 19:38

>>7

Name: Anonymous 2008-03-28 19:40

>>9

Name: Anonymous 2008-03-28 19:46

>>8

Name: Anonymous 2008-03-28 20:48

Not optimising your pile of Sepples shit.

Name: Anonymous 2008-03-28 21:20

>>11

Not optimising your face, faggot.

Name: Anonymous 2008-03-28 21:25

Too much cout, cin.

Please remove these!

Name: Anonymous 2008-03-28 21:34

>>12
see
>>13

Name: Anonymous 2008-03-28 22:18

>>13

And replace with what?

Name: Anonymous 2008-03-28 22:25

itt homework

Name: Anonymous 2008-03-28 22:31

>>15
printf(), scanf()

Good luck!!

Name: Anonymous 2008-03-28 22:35

fgets & sscanf so you don't leave bullshit in your stream fag

Name: Anonymous 2008-03-29 0:03

Why was cin and cout made if scanf() and printf() are apparently better?

Name: Anonymous 2008-03-29 0:05

Because Sepples

Name: Anonymous 2008-03-29 0:10

namespace std;

Name: Anonymous 2008-03-29 0:14

>>21
namespace stud;

Name: Anonymous 2008-03-29 0:23

>>22
are you coming on to me?....

Name: Anonymous 2008-03-29 0:24

>>23
Yeas! So what?

Name: Anonymous 2008-03-29 0:32

>>24
I'm sorry, but there is only one man who was ever able to tame the beast in my pants, i don't think you could compare with RMS

Name: Anonymous 2008-03-29 0:41

>>25
Rimmis? Fuck Rimmis.

Name: Anonymous 2008-03-29 3:09

Circumfrence

I could probably rewrite what you did in half the lines, but I'm not going to.

Name: Anonymous 2008-03-29 3:09

Your code looks like shit

START ALL OVER AND TRY AND MAKE IT LESS LINES AND LESS UGLY YOU PIG STUPID SHIT


SERIOUSLY I HOPE YOU ARE 12

Name: Anonymous 2008-03-29 13:47


#include <iostream>

int main()
{
  cout << "LEARN FUCKING GEOMETRY YOU BITCH IDIOT\n";
  return -32768;
}

Name: Anonymous 2008-03-29 14:33

geo.tar.gz.b64:

H4sIABqL7kcAA+3PwWrCQBAG4D3vUwx60UNlszEbwVCoNtqgNSDxIPSypEEiupHs5iS+e6N47VEL
5f8uP8PMwMyuqAb56cQeSbSUENeUSqlr+qG81Tde4DNPhKEfiKBtMOFJOVSMxEOvumus0zURs3u9
0+73Oeua78I4+4ybnqhbmvzQfkZRWVlXF/r4ynlpHB11aXp9fuZEedU4iiLqLOO39Ypmm+kiWc1p
Hqefcbbe0jbd0CTJph+UvCdp9mU643arLlxTG3rxZahGY37hf/0qAAAAAAAAAAAAAAAAAAAAAADA
v/IDECSYAgAoAAA=

Name: Anonymous 2008-03-30 0:37

Where are your .H's? This is not enterprise-quality code...

Name: Anonymous 2009-03-06 6:01


Start you nigger so   it all worked.

Name: Anonymous 2009-07-12 6:26

Java useful Java Java like readable like

Name: Anonymous 2010-11-27 10:40

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List