Elevator program

This is a discussion on Elevator program within the C++ Programming forums, part of the General Programming Boards category; I am working on a program that acts like an elevator. The user should be able to enter a destination ...

  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
    Attached Files Attached Files

  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,670
    Unless of course if we're going down the basement, in which case, that would be accurate, eh?



    ITSA
    Socket Library!

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,670
    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?



    ITSA
    Socket Library!

  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,670
    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!!



    ITSA
    Socket Library!

  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,670
    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



    ITSA
    Socket Library!

  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,136
    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,670
    Hey, you are latino - I just knew it!

    ie: "!!! Goooooooooooooooooooooooooooooooooooooal !!!"



    ITSA
    Socket Library!

  13. #13
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    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,670
    Ummm, no. You mean Mike "the overflow" Buffer, of dubious programming fame?
    Last edited by Sebastiani; 11-01-2002 at 10:14 PM.



    ITSA
    Socket Library!

  15. #15
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    ¡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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21