Simple Hotel Front-Desk System.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #16
    Originally posted by sukatoa
    Just a quick,

    What if i will not serialized my classes...
    eg. not setting the serialVersionUI D....
    What will happen to my program?
    What will be the disadvantage of doing like this?

    waiting for your replies,
    sukatoa
    Nothing much will happen, you just can't serialize instances of your classes then.
    It depends on what you want to do with those instances.

    kind regards,

    Jos

    Comment

    • sukatoa
      Contributor
      • Nov 2007
      • 539

      #17
      Originally posted by JosAH
      Nothing much will happen, you just can't serialize instances of your classes then.
      It depends on what you want to do with those instances.

      kind regards,

      Jos
      Thanks for the reply Jos.

      I don't no what should be the most important about it. Other says, they will be useful if i will implement it through a module type updating of a software.

      As an exception occurs when the serialVersionUI D of the software is not exactly/logically equal to the module to be used for updating the said software..
      It is true?

      By the way, i will not delete those settings, maybe this might be useful soon...
      (Obviously im not aware of it)....

      Here we go,

      About for each statement,

      which is faster,

      [CODE=JAVA]for(Object store:ROOMS.get UniqueKeys(true ).toArray()){
      dlm.addElement( store);
      }[/CODE]

      or

      [CODE=JAVA]Object[] t = ROOMS.getUnique Keys(true).toAr ray();
      for(Object store:t){
      dlm.addElement( store);
      }[/CODE]

      I doubt about the REAL algorithm of for:each statement....

      Can you discuss me here Jos? and somebody here in java forum who knows the real algo of for:each statement(they way it performs).....
      Or the best URL you know that explains it well?

      Waiting for your replies,
      sukatoa <----- stucked.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #18
        What is the return type of getUniqueKeys() ? If it is a collection you don't have
        to turn it into an array first to use the new for-each loop.

        kind regards,

        Jos

        Comment

        • sukatoa
          Contributor
          • Nov 2007
          • 539

          #19
          Originally posted by JosAH
          What is the return type of getUniqueKeys() ? If it is a collection you don't have
          to turn it into an array first to use the new for-each loop.

          kind regards,

          Jos
          Thanks for the reply,

          An ArrayList that contents all the keys to be shown on the JList....

          dlm is an object of DefaultListMode l.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #20
            Originally posted by sukatoa
            Thanks for the reply,

            An ArrayList that contents all the keys to be shown on the JList....

            dlm is an object of DefaultListMode l.
            If that is so you can do a simple:

            [code=java]
            for (Room room : getUniqueKeys(t rue))
            dlm.addElement( room);
            [/code]

            The getUniqueKeys() method returns a Collection (an ArrayList) which can be
            used directly in that for-each loop.

            kind regards,

            Jos

            Comment

            • sukatoa
              Contributor
              • Nov 2007
              • 539

              #21
              Originally posted by JosAH
              If that is so you can do a simple:

              [code=java]
              for (Room room : getUniqueKeys(t rue))
              dlm.addElement( room);
              [/code]

              The getUniqueKeys() method returns a Collection (an ArrayList) which can be
              used directly in that for-each loop.

              kind regards,

              Jos
              Ooppss!!! Let me correct my phrase...

              An ArrayList that contains all the keys to be shown on the JList....

              Im sorry, i forgot to say Jos.....

              ROOM is an object created from my DataSetHandler class...
              ( a public class that implements Serializable and takes care of data sets ).

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #22
                Originally posted by sukatoa
                Ooppss!!! Let me correct my phrase...

                An ArrayList that contains all the keys to be shown on the JList....

                Im sorry, i forgot to say Jos.....

                ROOM is an object created from my DataSetHandler class...
                ( a public class that implements Serializable and takes care of data sets ).
                It still doesn't matter: if that method returns a List of some sort you can still use
                that for-each loop on it; no need to build an array out of it first and use that loop
                on the array.

                kind regards,

                Jos

                Comment

                • sukatoa
                  Contributor
                  • Nov 2007
                  • 539

                  #23
                  Originally posted by JosAH
                  It still doesn't matter: if that method returns a List of some sort you can still use
                  that for-each loop on it; no need to build an array out of it first and use that loop
                  on the array.

                  kind regards,

                  Jos
                  That example you've posted is really new to me...
                  I'll try and update the results...

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #24
                    Originally posted by sukatoa
                    That example you've posted is really new to me...
                    I'll try and update the results...
                    Read this.

                    kind regards,

                    Jos

                    Comment

                    • sukatoa
                      Contributor
                      • Nov 2007
                      • 539

                      #25
                      Originally posted by sukatoa
                      That example you've posted is really new to me...
                      I'll try and update the results...
                      Ok, That scenario happens on my main class named Hotel....

                      Can't find Symbol..... I doubt...

                      parameter of addElement is Object type....

                      maybe i can just invoke the getUniqueKeys if my DataSetHandler was extends on my Main class.....

                      But it was already extends on JFrame...

                      Please correct me if i forgot something to adjust.....

                      Comment

                      • sukatoa
                        Contributor
                        • Nov 2007
                        • 539

                        #26
                        Ahhh, ok... i got an idea....

                        Here is the current method that implements the for each....

                        [CODE=JAVA]private void UpdateRoomList( ){
                        if(RetrieveRoom List()){
                        dlm.removeAllEl ements();
                        Object[] t = ROOMS.getUnique Keys(true).toAr ray();
                        for(Object o:t)
                        dlm.addElement( o);
                        }else{
                        shw.showMessage Dialog(null,
                        "An error occured while updating the list on room preference",
                        "Report to the Developer ASAP..",1);
                        }
                        }[/CODE]

                        Maybe your example is not applicable on the method's design....
                        But im impress the way how it simplified... base on the URL you've post....

                        I should change this...

                        Thanks Jos,
                        sukatoa

                        Comment

                        • JosAH
                          Recognized Expert MVP
                          • Mar 2007
                          • 11453

                          #27
                          Originally posted by sukatoa
                          Ahhh, ok... i got an idea....

                          Here is the current method that implements the for each....

                          [CODE=JAVA]private void UpdateRoomList( ){
                          if(RetrieveRoom List()){
                          dlm.removeAllEl ements();
                          Object[] t = ROOMS.getUnique Keys(true).toAr ray();
                          for(Object o:t)
                          dlm.addElement( o);
                          }else{
                          shw.showMessage Dialog(null,
                          "An error occured while updating the list on room preference",
                          "Report to the Developer ASAP..",1);
                          }
                          }[/CODE]

                          Maybe your example is not applicable on the method's design....
                          But im impress the way how it simplified... base on the URL you've post....

                          I should change this...

                          Thanks Jos,
                          sukatoa
                          No need to do it that way if the getUniqueKeys() method returns a List of some sort:

                          [code=java]
                          for(Object o: ROOMS.getUnique Keys(true))
                          dlm.addElement( o);
                          [/code]

                          kind regards,

                          Jos

                          Comment

                          • sukatoa
                            Contributor
                            • Nov 2007
                            • 539

                            #28
                            Originally posted by JosAH
                            No need to do it that way if the getUniqueKeys() method returns a List of some sort:

                            [code=java]
                            for(Object o: ROOMS.getUnique Keys(true))
                            dlm.addElement( o);
                            [/code]

                            kind regards,

                            Jos
                            Wow, i thought that was not possible to implement....
                            Thinking that all values of the list are Objects.... :) I amazed...

                            Thanks Jos,

                            When we compare the code

                            [CODE=JAVA]ArrayList al = ROOMS.getUnique Keys(true);
                            for(Object o: al)
                            dlm.addElement( o);[/CODE]

                            to your example,

                            Does it make any sense? Which should be the better/faster one?

                            Comment

                            • JosAH
                              Recognized Expert MVP
                              • Mar 2007
                              • 11453

                              #29
                              Originally posted by sukatoa
                              Wow, i thought that was not possible to implement....
                              Thinking that all values of the list are Objects.... :) I amazed...

                              Thanks Jos,

                              When we compare the code

                              [CODE=JAVA]ArrayList al = ROOMS.getUnique Keys(true);
                              for(Object o: al)
                              dlm.addElement( o);[/CODE]

                              to your example,

                              Does it make any sense? Which should be the better/faster one?
                              That makes sense and it doesn't differ much from my example, you are just using
                              a needles local variable. Your previous versions however created an explicit array
                              and you looped over the array.

                              Your next step should be to use generics for type safety, i.e. that list of yours
                              doesn't contain just Objects, it contains something more specific.

                              kind regards,

                              Jos

                              Comment

                              • sukatoa
                                Contributor
                                • Nov 2007
                                • 539

                                #30
                                Originally posted by JosAH
                                That makes sense and it doesn't differ much from my example, you are just using
                                a needles local variable. Your previous versions however created an explicit array
                                and you looped over the array.

                                Your next step should be to use generics for type safety, i.e. that list of yours
                                doesn't contain just Objects, it contains something more specific.

                                kind regards,

                                Jos
                                Ok....

                                Thank you very much....

                                Comment

                                Working...