Thread: Elevator program

  1. #1
    Registered User brianptodd's Avatar
    Join Date
    Oct 2002
    Posts
    66

    Elevator program

    I am working on a program that acts like an elevator. The user should be able to enter a destination floor between 1 and 20. Say the user enters 5. The program output should be:

    The doors are closing.

    Going up to floor 2.
    Going up to floor 3.
    Going up to floor 4.

    The elevator is on floor 5.
    Please enter a new destination floor.

    And if the user enters 2, then the output should look like:

    The doors are closing.

    Going down to floor 2.
    Going down to floor 3.
    Going down to floor 4.

    The elevator is on floor 5.
    Please enter a new destination floor.

    I need to write a class to use with this program. I have included what I have completed of the class. I need help on writing the loops to control the elevator up and down.

    Thanks for the help.

    Brian

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    And if the user enters 2, then the output should look like:
    The doors are closing.

    Going down to floor 2.
    Going down to floor 3.
    Going down to floor 4.

    The elevator is on floor 5.
    Errr... do you mean:
    Code:
    The doors are closing.
    
    Going down to floor 4.
    Going down to floor 3.
    Going down to floor 2.
    
    The elevator is on floor 2.
    Otherwise I am completely confused...

  3. #3
    Registered User brianptodd's Avatar
    Join Date
    Oct 2002
    Posts
    66
    Right...going to floor 4, 3, 2, etc. Sorry for the confusion.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Unless of course if we're going down the basement, in which case, that would be accurate, eh?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Code:
    
    //...syntax error...
    int  Elevator::getMinFloor() const
    {
    	return(_MinFloor)
    }
    
    
    //...code does nothing plus returns nothing..
    bool Elevator::getDoorStatus() const
    {
    	_DoorStatus = false;
    	_DoorStatus = true;
    }
    
    
    //...forget something?
    void Elevator::setMinMaxFloors(int minFloor, int maxFloor)
    {
    
    }
    
    
    //...it says "print" not alter...
    void Elevator::printDoorStatus()
    {
    	if(_doorOpen)
    	{
    		cout << "Open at floor " << _currentFloor << endl;
    		_doorOpen = false;
    	}
    	else
    	{
    		cout << "Doors are Closing" << endl;
    		_doorOpen = true;
    	}
    }


    Next:


    Code:
    //...This function shows the most minimal effort on your part...
    
    void Elevator::move(int destinationFloor)
    {
    	// check for valiation of the destinationFloor
    	// call validateFloor(destination)
    
    
    
    	if(destinationFloor > _currentFloor)
    		goUp(destinationFloor);
    	else if(destinationFloor < _currentFloor)
    		goDown(destinationFloor);
    	else
    		printDestinationFloor();
    
    	printDoorStatus();
    
    	// print the door status
    }



    This class is fully 100 lines less than it should be, shouldn't you be trying a little harder? I'd be glad to help, but then why reward laziness?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  6. #6
    Registered User brianptodd's Avatar
    Join Date
    Oct 2002
    Posts
    66

    sebastiani

    You've replied to some of my posts in the past and have been less than helpful. So if you choose not to post anything else that's fantastic with me.

    However, in the future, if you do post, try to relate it to the question being asked, rather than using the board to grace us your personal, half-assed psychological evaluations.

    My original question, and I quote, " I need to write a class to use with this program. I have included what I have completed of the class. I need help on writing the loops to control the elevator up and down." I didn't ask anyone to finish my class. All I asked was for someone to help me out with the loops to print out the floor numbers as the elevator moves down. I simply included the class file as a reference, not as a finished product.

    Too bad that seems difficult for you to understand.

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    You've replied to some of my posts in the past and have been less than helpful.
    Does that tell you nothing?

    My single point is that your "class" looks like a half hearted attempt to me. You cannot work like that. If I saw a pound of sweaty code I wouldn't be so hard on you, but from the looks of it all you have is a glorified get/set class. Get to work!!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #8
    Registered User brianptodd's Avatar
    Join Date
    Oct 2002
    Posts
    66

    get/set class???

    That's all I'm looking for. This is the first class I am being required to write. I'm a first semester student. This isn't something I'm being paid to do, nor is it something that I'm trying to "con" someone into writing for me.

    I don't mind someone "being hard on me" as long as it's constructive. I'm simply learning here, or at least trying to. I understand that this class is nowhere near complete, but the point I'm at is the loops. So that's what I was asking help for, not for someone to finish my class.

    The thing that set me off was the lazy comment. I don't know you, but I wouldn't post that you were lazy. (Even if I knew it to be true, which you don't.)

    Anyway, I think I have figured out the loops, so you're just wasting my time. Unless you had something to say....

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Ok, I'll try to be objective then. I understand that programming isn't learned all at once, I just thought you were being lazy

    So you've figured it out then? Just repost if you have any questions and I'll keep the psychoanalysis to myself

    -Sebastian
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  10. #10
    Registered User brianptodd's Avatar
    Join Date
    Oct 2002
    Posts
    66
    Deal.

  11. #11
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Ladies and Gentleman,
    Welcome to tonight's main bout. In the left corner, we have the Pro who is in the know, Sebastiani. In the right corner, we have the kid who has never hid, brianptodd. For the thousands in attendance, and the millions watching at home, ladies and gentleman, let'sssssssssssss get reaaaaaaaaaady to rummmmmmmmmmmblllllllllllllllle.



  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Hey, you are latino - I just knew it!

    ie: "!!! Goooooooooooooooooooooooooooooooooooooal !!!"
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  13. #13
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Nah, my name is Michael Buffer (I hope you know who that is).

  14. #14
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Ummm, no. You mean Mike "the overflow" Buffer, of dubious programming fame?
    Last edited by Sebastiani; 11-01-2002 at 11:14 PM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  15. #15
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    ¡Aye de mi!

    Michael Buffer is a famous ring announcer. He is famous for his phrase "Let's get ready to rumble." The way he says it, he extends Let's, ready, and rumble.

Popular pages Recent additions subscribe to a feed