Vending Machine - Header files and Member Function Definitions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vpascuzzi
    New Member
    • Mar 2007
    • 23

    Vending Machine - Header files and Member Function Definitions

    Here's the deal:

    I've been working on this little program forever now, and can't seem to get the final little glitches out of it.

    I am to build a vending machine, using 2 header .h files (one for the cash register and the other for the dispenser), and 2 member function definitions .cpp (one for each).

    It is a little lengthy, and there are 5 files so I uploaded them to my webspace. If anyone could take a look at my code and possibly fix it and make it work fully before I do, that'd be really great! Any help asap would be greatly appreciated!

    I've included the URL to the files at the bottom of this post. If anyone happens to get this before me, feel free to email me with the files.

    Thanks to you all in advance!

    -------------------------------------------------------------------------------------------------------------------

    URL: http://home.cogeco.ca/~iscooze/vendingMachine/
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    the only major problem I can see is you have a ; missing from the end of DISPENSER.H which would generate errors with you compile DISPENSER.cpp
    Code:
    } // end class DISPENSER
    it should be
    Code:
    }; // end class DISPENSER
    what other problem do you have?

    Comment

    • vpascuzzi
      New Member
      • Mar 2007
      • 23

      #3
      Originally posted by horace1
      the only major problem I can see is you have a ; missing from the end of DISPENSER.H which would generate errors with you compile DISPENSER.cpp
      Code:
      } // end class DISPENSER
      it should be
      Code:
      }; // end class DISPENSER
      what other problem do you have?
      Compile errors in defining new definitions in the default constructor. It's just been very tedious.

      Did you try to compile it yourself? I cannot get the driver to work with the classes. For example, making objects to use.

      Comment

      • vpascuzzi
        New Member
        • Mar 2007
        • 23

        #4
        Actually, adding in the ' ; ' made it compile! :)

        Now, if you have any help on maing the program run and come together, it'd be greatly appreciated!


        Thanks!

        Comment

        • horace1
          Recognized Expert Top Contributor
          • Nov 2006
          • 1510

          #5
          Originally posted by vpascuzzi
          Actually, adding in the ' ; ' made it compile! :)

          Now, if you have any help on maing the program run and come together, it'd be greatly appreciated!


          Thanks!
          this compiled and ran OK
          Code:
          #include <iostream>
          #include <conio.h>
          using namespace std;
          
          #include "DISPENSER.h"
          #include "CASHREGISTER.h"
          
          int main( )
          { 
              CASHREGISTER cash(500);
              DISPENSER disp;
              cash.currentBalance();
              system("pause");
              }; // end main
          from this you can build up a program testing each function in turn

          Comment

          • vpascuzzi
            New Member
            • Mar 2007
            • 23

            #6
            I tried compiling that code into the main, but it does not work. I tried both Borland 5 and Dev C++.

            I get an error in Dev like this:

            Makefile.win
            $(BIN): $(OBJ)

            Multiple target patterns. Stop.

            I don't know what the problem is! It is driving me mad! I don't know how the project does not compile.

            I just want to test the displayMessage( ) function, to get a starting point on running and debugging the functions one at a time.

            Any ideas?

            Comment

            • vpascuzzi
              New Member
              • Mar 2007
              • 23

              #7
              I guess you can disregard my last post, just because I tend to be a bonehead when it comes to the simplest things.

              The reason I was getting the compiler error was because I did not have all of my files saved in the same directory. They were in a different dir than my project file, causing this error.

              Anyways, I think I can handle it from here, and thanks for the help earlier. I'll keep you up to date on my progress!

              Originally posted by vpascuzzi
              I tried compiling that code into the main, but it does not work. I tried both Borland 5 and Dev C++.

              I get an error in Dev like this:

              Makefile.win
              $(BIN): $(OBJ)

              Multiple target patterns. Stop.

              I don't know what the problem is! It is driving me mad! I don't know how the project does not compile.

              I just want to test the displayMessage( ) function, to get a starting point on running and debugging the functions one at a time.

              Any ideas?

              Comment

              • vpascuzzi
                New Member
                • Mar 2007
                • 23

                #8
                Code:
                #include <iostream>
                #include <conio.h>
                using namespace std;
                
                #include "DISPENSER.h"
                #include "CASHREGISTER.h"
                
                int main( )
                {
                
                    DISPENSER disp;
                    CASHREGISTER cash( 500 );
                    
                    disp.userOption( int userAnswer );
                
                    return 0;
                
                }; // end main
                14 C:\Documents and Settings\vpascu zzi\My Documents\Schoo l\VENDINGMACHIN E_DRIVER.cpp expected primary-expression before "int"

                This won't run. I'm not 100% sure on the syntax of creating an object and using the functions.

                Any suggestions?

                Comment

                • vpascuzzi
                  New Member
                  • Mar 2007
                  • 23

                  #9
                  Ok, for the most part I have this thing working. I know my driver .cpp is screwy because depending on what options I choose, I sometimes I have to input the same answer twice.

                  If someone could take a look at it from:

                  http://home.cogeco.ca/~iscooze

                  It's mostly in the driver that things aren't going smoothly. My values are all assigned to '0'.

                  Any help would be appreciated.


                  Thanks!

                  Comment

                  • vpascuzzi
                    New Member
                    • Mar 2007
                    • 23

                    #10
                    Completed!!!

                    Hooray!!!

                    After a few more hours of hard work and debugging, my program finally works properly and is stable! Just wanted to give a big thanks to horace1 and anybody else who at least read my post.

                    I'll be around for a while, so if any of you have any questions, I'll be sure to give any advice I can!

                    Thanks thescripts.com!

                    ----------------------------------

                    URL of completed vending machine: Vending Machine Solution and Executable
                    Last edited by vpascuzzi; Mar 6 '07, 05:49 AM. Reason: mispelled moderator's name

                    Comment

                    Working...