The movie rental program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nkhosinathie
    New Member
    • May 2007
    • 91

    The movie rental program

    i've be given this task to do. as a member i want to learn this program while i'm doing it with you.i'm hoping i'll be with you through the next two hours.
    this is the program below.


    Program 2
    MULTICHOICE VIDEO RENTAL SHOP needs an Object Oriented program that process the following information about ten (10) videos in their stock
    • The title, the director, the year produced and a list of main actors for each video. (If there are more than five main actors, include only the five most famous actors)
    • The function setVideo that input information into each video object
    • The function getVideo that displays information of a particular video on the screen
    • A customer (identified by ID) plus his full names and address can borrow at most 2 videos @ R12.50 per day. A penalty of 10% per day is charged if returned late. The borrow period is at most 7 days
    • Video titles should not exceed 25 characters in length. If that happens, truncate the length to a most 25 characters
    • A video should be checked if is not rented out before borrow transaction is processed. If borrowed out the customer should either be requested for the second choice or be advised when the video is expected back in the shop
    • Failure for the shop to receive the video back within 7 days, is considered permanent loss and the customer is liable to a R400.00 compensation fee
    • Information about the number of films in stock at any point in time should be readily available
    • At the end of business, a report should be generated showing
    o Which films are rented out and when are they due
    o To which customers they are borrowed to
    o Which videos are left in stock
    o How much money was collected for the day
    Generate your own test data that will test all cases to illustrate the accuracy and consistency of your program


    so i'm not sure whether to use two classes,or to use struct customer and a movie class.
  • Nkhosinathie
    New Member
    • May 2007
    • 91

    #2
    this is the first part of my program including two classes one for the video and the other for customers

    Code:
    code[c++]

    #include<iostre am>
    #include<iomani p>
    #include<string >

    class Video{

    private:
    string Title;
    string Director;
    int Year;
    string Actors;

    public:
    Video(string title,string director,int year,string actors)
    {
    SetVideo(title, director,year,a ctors);

    }
    void SetVideo(string title,string director,int year,string actors)
    {
    Title=title;

    Title=(title>=0 && title<25) ? title:25;

    Director=direct or;

    Year=year;
    Year=(year<=0 && year<2007) ? year:1900;
    Actors=actors;

    }
    void GetVideo()
    {
    cout<<Title<<"\ n"
    <<Director<<"\n "
    <<Year<<"\n"
    <<Actors<<"\n\n ";

    }

    };
    class Customer{
    private:
    string Id;
    string Name;
    string Address;

    public:
    Customer(string id,string name,string address)
    {
    SetInfo(id,name ,address);
    }
    void SetInfo(string id,string name,string address)
    {
    Id=id;
    Name=name;
    Address=address ;

    }
    void GetInfo()
    {
    cout<<Id<<"\n"
    <<Name<<"\n"
    <<Address<<"\n\ n";
    }

    Comment

    • Nkhosinathie
      New Member
      • May 2007
      • 91

      #3
      please guys i'm frustrated

      [code=cpp]
      l#include<iostr eam>
      #include<iomani p>
      #include<string >
      using namespace std;

      struct Video
      {

      string title;
      string director;
      int year;
      string actors;
      };


      struct Customer
      {
      string id;
      string name;
      string address;
      };

      void GetInfo(Custome r[]);
      void GetVideo(Video[],int);
      //void SetVideo(Video[],int;

      int main()
      {
      int loop;

      Video myInfo[7];Customer info[3];
      GetInfo(info);
      cout<<"how many movies you are adding?:";
      cin>>loop;
      cin.get();
      Video total[10];
      for(int x=0;x<loop;x++)
      {
      GetVideo(myInfo ,loop);
      }
      //SetVideo(myInfo ,loop);

      return 0;


      }
      void GetVideo(Video movie[],int loop)
      {
      int number;

      for(int x=0;x<loop;x++)
      {

      cout<<"Movie Info:\n\n";
      cout<<"Title:";
      getline(cin,mov ie[x].title);
      cin.get();
      cout<<"Director :";
      getline(cin,mov ie[x].director);
      cout<<"Year Produced:";
      cin>>movie[x].year;
      cin.get();
      cout<<"How many Actors?";
      cin>>number;

      for(int y=0;y<number;y+ +)
      {
      cout<<"Actor:";
      getline(cin,mov ie[y].actors);
      cout<<"\n\n";
      }
      cout<<"\n\n";
      }


      }
      void GetInfo(Custome r info[])
      {
      for(int x=0;x<1;x++)
      {
      cout<<"Client Info:\n\n";
      cout<<"Id:";
      getline(cin,inf o[x].id);
      cin.get();
      while(info[x].id!= "13" )
      {
      cout<<"wrong ID number\n";
      cout<<"enter a (13-digit)number please:";
      getline(cin,inf o[x].id);
      }
      cin.get();
      cout<<"Name:";
      getline(cin,inf o[x].name);
      cout<<"Address: ";
      cin.get();
      getline(cin,inf o[x].address);
      cout<<"\n\n";
      }



      }[/code]
      Last edited by sicarie; Oct 25 '07, 02:28 PM. Reason: Code tags

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by Nkhosinathie
        please guys i'm frustrated
        Where are you frustrated? What are you trying to do that's not working? How is it not working? Come on, Nkhosinathie, you've been here long enough to know how this is supposed to work, you have to help us!

        PS - Next time you respond/create a thread, please read the box on the right side of the page very carefully - they will show you how to use code tags properly.

        Comment

        • Nkhosinathie
          New Member
          • May 2007
          • 91

          #5
          Originally posted by sicarie
          Where are you frustrated? What are you trying to do that's not working? How is it not working? Come on, Nkhosinathie, you've been here long enough to know how this is supposed to work, you have to help us!

          PS - Next time you respond/create a thread, please read the box on the right side of the page very carefully - they will show you how to use code tags properly.
          thank you Sicarie,my problem firstly is to assign those ten movies inside one array so that when i need those movies i can get them there.

          Comment

          • sicarie
            Recognized Expert Specialist
            • Nov 2006
            • 4677

            #6
            Okay, in your main you create a list of videos with

            [code=cpp]
            Video myList[7];
            [/code]

            and then do another with

            [code=cpp]
            Video total[10];
            [/code]

            Why both? And you have the right general idea - but can I ask you to look at this:

            [code=cpp]
            for(int x=0;x<loop;x++)
            {
            GetVideo(myInfo ,loop);

            /*
            ...
            */

            void GetVideo(Video movie[],int loop)
            {
            int number;

            for(int x=0;x<loop;x++)
            {
            [/code]

            Why do you have two loops there? You only need one. You can choose to keep everything local and call GetVideo separately from main() to get each info set, or you can pass the number to GetVideo() and do it there, but you don't need to do it in both. Just one thing to think about, though, what if you only want to do it once? Do you really want to have to remember to pass 1 to GetVideo() every time you want to call it once?

            There are still a few other things, but I would start there.

            Comment

            • Nkhosinathie
              New Member
              • May 2007
              • 91

              #7
              Originally posted by sicarie
              Okay, in your main you create a list of videos with

              [code=cpp]
              Video myList[7];
              [/code]

              and then do another with

              [code=cpp]
              Video total[10];
              [/code]

              Why both? And you have the right general idea - but can I ask you to look at this:

              [code=cpp]
              for(int x=0;x<loop;x++)
              {
              GetVideo(myInfo ,loop);

              /*
              ...
              */

              void GetVideo(Video movie[],int loop)
              {
              int number;

              for(int x=0;x<loop;x++)
              {
              [/code]

              Why do you have two loops there? You only need one. You can choose to keep everything local and call GetVideo separately from main() to get each info set, or you can pass the number to GetVideo() and do it there, but you don't need to do it in both. Just one thing to think about, though, what if you only want to do it once? Do you really want to have to remember to pass 1 to GetVideo() every time you want to call it once?

              There are still a few other things, but I would start there.
              thank you sicarie,the past i was doing the general programming now we have changed to the object's programming so i'm really struggling.anyw ay i created two loops because i'm enterring the video information and at the same time i'm taking each movie inside video total. so how can i put all this ten movies into one array?

              Comment

              • Nkhosinathie
                New Member
                • May 2007
                • 91

                #8
                Originally posted by Nkhosinathie
                thank you sicarie,the past i was doing the general programming now we have changed to the object's programming so i'm really struggling.anyw ay i created two loops because i'm enterring the video information and at the same time i'm taking each movie inside video total. so how can i put all this ten movies into one array?
                please i seriously need your help here

                Comment

                • Nkhosinathie
                  New Member
                  • May 2007
                  • 91

                  #9
                  Originally posted by Nkhosinathie
                  please i seriously need your help here
                  please,please i need some fresh ideas please

                  Comment

                  • Nkhosinathie
                    New Member
                    • May 2007
                    • 91

                    #10
                    Originally posted by Nkhosinathie
                    please,please i need some fresh ideas please
                    i'm next to a compiler now,so i did compile my sorce-code and there are no errors.so my question is how can i assign all the ten movies that i'm entering inside the getVideo function? anyone help please!

                    Comment

                    • sicarie
                      Recognized Expert Specialist
                      • Nov 2006
                      • 4677

                      #11
                      Nkhosinathie-

                      You are a member of this community, and we enjoy not only helping you, but your ideas and input in discussions raised. It's always good to have someone new to the material because they think of new things and new ways to look at it.

                      That being said, you have been here long enough and pointed to the Programming Guidelines enough times that you need to start strictly adhering to them. The Mods are going to have to start taking actions against you soon due to the disruption and the amount of work it takes to clean up after you.

                      The link to the Guidelines is above, but in this thread specifically, 1) be paitent. We volunteer our time, and we can't be on 100% of the time. You have the benefit of all the registered members as well as the mods, and someone will be around eventually. 2) code tags. I think we've spoken about this, 3) paying attention to what is written and playing with it yourself. If you look at the last part of what I posted, you will see I say that you can do that one of two places, but not both of the places you have it set. I would recommend doing it in your main() and removing it from GetVideo().

                      We would like you to stay around, so please start playing around with your code and learning the theory behind not only what we are saying, but also what your instructor is saying. They are "big-picture" trying to get you through OOP, and we're looking at the smaller picture helping with your individual assignment.

                      Have another look at GetVideo and where it is called (specifically the loop where it is called). You have two control structures set up to populate your array, and you need to choose one of those locations to do it.

                      Comment

                      Working...