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

C#

Name: Anonymous 2009-08-14 20:29

OK,

I need to make an array for an amount of rooms, the price, and address for dwellings. I have the properties in a class, but in Main I need to have the user input the amount of rooms, price, and address (3 different entries) and have the inputs go to an array. But how do I get the inputs to go to the array, while still using the 'filtering' code in their properties in the class?


I am confused beyond confused, and I'm sure you are after reading this. But if you can help, thank you.

Name: Anonymous 2009-08-14 23:19

>>24
That's why you're stunned. /b/ is your home.

Incidentally, have some enterprise Sepples.

#include "Types.h"

class Point {
public:
    Point() : x(0), y(0) { }
    Point(int32_t x, int32_t y) : x(x), y(y) { }

    int32_t getX() const { return x; }
    int32_t getY() const { return y; }
    void setX(int32_t nx) { x = nx; }
    void setY(int32_t ny) { y = ny; }

    Point & operator =(const Point &rhs) {
        if (this != &rhs) {
            x = rhs.x;
            y = rhs.y;
        }
        return *this;
    }
    bool operator ==(const Point &rhs) const { return (rhs.x == x && rhs.y == y); }
    bool operator !=(const Point &rhs) const { return !(*this == rhs); }
protected:
    int32_t x;
    int32_t y;
};

class Line {
public:
    Line() : a(Point()), b(Point()) { }
    Line(const Point &start, const Point &end) : a(start), b(end) { }

    void setStart(const Point &start) { a = start; }
    void setEnd(const Point &end) { b = end; }

    int32_t getLength() const { return (int32_t)(sqrt((float)((a.getX() - b.getX()) * (a.getX() - b.getX()) + (a.getY() - b.getY()) * (a.getY() - b.getY())))); }
protected:
    Point a;
    Point b;
};

class Shape {
public:
    Shape() { }
    virtual int32_t getArea() const = 0;
    virtual int32_t getPerimeter() const = 0;
};

class Square : public Shape {
public:
    Square() : length(0) { }
    Square(int32_t length) : length(length) { }

    int32_t getArea() const { return length * length; }
    int32_t getPerimeter() const { return length * 4; }
    int32_t getLength() const { return length; }
    void setLength(int32_t length) { this->length = length; }

    Square & operator =(const Square &rhs) {
        if (this != &rhs)
            length = rhs.length;
        return *this;
    }
    bool operator ==(const Square &rhs) const { return (rhs.length == length); }
    bool operator !=(const Square &rhs) const { return !(*this == rhs); }
protected:
    int32_t length;
};

class Rectangle : public Square {
public:
    Rectangle() : Square(0), width(0) { }
    Rectangle(int32_t length, int32_t width) : Square(length), width(width) { }

    int32_t getArea() const { return length * width; }
    int32_t getPerimeter() const { return length * 2 + width * 2; }
    int32_t getWidth() const { return width; }
    void setWidth(int32_t width) { this->width = width; }

    Rectangle & operator =(const Rectangle &rhs) {
        if (this != &rhs) {
            length = rhs.length;
            width = rhs.width;
        }
        return *this;
    }
    bool operator ==(const Rectangle &rhs) const { return (rhs.length == length && rhs.width == width); }
    bool operator !=(const Rectangle &rhs) const { return !(*this == rhs); }
protected:
    int32_t width;
};

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