6 Replies Latest reply: May 17, 2007 12:48 PM by 807600 RSS

    Class design without useing extends question

    807600
      Hello everyone:
      I have one last project that is due today and I have a question. Class assignment the Airliner...
      In this project that I'm working on it has several class in which each class has some data type it needs to use. It also need to two programs one to capture the required info. the other will create the user interface and db connections

      I think I need at least three class.
      Ticket
      Buyer
      The third one to conatin the main() to do the testing.

      Question is I don't think I can use extends from what I have being read. So the question is how do I get the info from TicketClass to the BuyerClass.
      The BuyerClass need info from the TicketClass in order to process a ticket and print out the in.

      any help would be great.

      nomad
        • 1. Re: Class design without useing extends question
          807600
          Hello everyone:
          I have one last project that is due today and I have
          a question. Class assignment the Airliner...
          In this project that I'm working on it has several
          class in which each class has some data type it needs
          to use. It also need to two programs one to capture
          the required info. the other will create the user
          interface and db connections

          I think I need at least three class.
          Ticket
          Buyer
          The third one to conatin the main() to do the
          testing.

          Question is I don't think I can use extends from what
          I have being read. So the question is how do I get
          the info from TicketClass to the BuyerClass.
          The BuyerClass need info from the TicketClass in
          order to process a ticket and print out the in.

          any help would be great.

          nomad
          You can create an instance of BuyerClass in TicketClass and use that instance to call functions in BuyerClass and pass whatever values you want to.

          example code:

          public class TicketClass{

          ticketFunction(){
          int value = 5; //value to be sent to BuyerClass
          BuyerClass buyer = new BuyerClass();
          a.buyerFunction(value);
          }
          } //end of class

          public Class BuyerClass{

          buyerFunction(int value){
          //do whatever you want to do with value
          }
          } //end of class

          hope this helps...
          • 2. Re: Class design without useing extends question
            807600
            Thanks for the help
            question what does the a do
            a.buyerFunction(value);

            red
            do i need to do this
            int a;
            • 3. Re: Class design without useing extends question
              807600
              Thanks for the help
              question what does the a do
              a.buyerFunction(value);

              red
              do i need to do this
              int a;
              I am sorry I mistyped... it should be buyer.buyerFunction(value) instead of a.buyerFunction(value)... buyer.BuyerFunction(value) will call the buyerFunction in BuyerClass and pass it the int value...
              • 4. Re: Class design without useing extends question
                807600
                thanks.
                One day I will understand Java...
                • 5. Re: Class design without useing extends question
                  807600
                  thanks.
                  One day I will understand Java...
                  that will be a good day indeed...
                  • 6. Re: Class design without useing extends question
                    807600
                    thanks.
                    One day I will understand Java...
                    that will be a good day indeed...
                    What did the monk say when he became enlightened? "I'm just as miserable as I ever was"?