Simple Hotel Front-Desk System.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #31
    After few weeks of developing.... ( slow development ) :(

    Im now facing a problem that i've never encountered before...

    And that problem is in my DataSetHandler. ...

    I've initialized ROOMS, CURRENTGUESTS and RESERVEDGUESTS (DataSetHandler objects) as members of the main class.

    @ RESERVEDGUESTS

    I've made a button(EDIT) to be able to update the data that was stored on RESERVEDGUESTS. ...

    [CODE=JAVA] if(!jList2.isSe lectionEmpty()) {
    Object ob = RESERVEDKEYS.ge t(jList2.getSel ectedIndex());
    ArrayList<Objec t> al = new ArrayList<Objec t>();
    al.add(RESERVED GUESTS.getNthEl ement(ob,0));
    al.add(RESERVED GUESTS.getNthEl ement(ob,15));
    al.add(RESERVED GUESTS.getNthEl ement(ob,16));
    DataSetHandler dsh = RESERVEDGUESTS; //<<<<<<SUSPECT ED
    dsh.removeDataS et(ob);
    new RegisterFilter( this,true,CURRE NTGUESTS,dsh,al ).setVisible(tr ue);
    if(new File("schedule. temp").exists() ){

    }
    }[/CODE]

    The code above is where i get stucked....
    On that implementation,
    I was just initializing dsh from DataSetHandler object RESERVEDGUESTS.

    my purpose is to remove the specific key and its member and pass to the Dialog that manipulates the rescheduling, guest's prefered rooms etc....

    RESERVEDGUESTS should not be touched... so i've created another one....
    If the editing is successful(upda ted), then no problem because the RSVN(Reservatio n) number was removed and replaced by a new one or the updated one....

    But if the editing was canceled, so the current values will just be refreshed...
    But, after refreshing the lists,

    I now can't find the key and its member.... ( nullpointerexce ption occured )...
    I get stucked for a half an hour, tracing that F* bug.

    and now it was proven 100% that the responsible for removing that key(supposed to be removed to use as a reference on editing) is the

    Code:
    DataSetHandler dsh = RESERVEDGUESTS; //<<<<<<SUSPECTED
                dsh.removeDataSet(ob);
    Base on my observation, the dsh and the RESERVEDGUESTS are one,
    I can't imagine, because on my other implementation, there was no problem...
    (That is exactly the same on this, the only difference is more keys was also removed)
    Base on the snippet above(that 2 lines), What's wrong?

    whatever i will do to dsh, RESERVEDGUESTS should not be changed right?
    But, the RESERVEDGUESTS is affected, whatever i did to dsh, it reflects to RESERVEDGUESTS. ... Please correct me( i might forgot something here)

    As i've remove the key ob in dsh, the RESERVEDGUESTS also affected,
    I expect that ob is still in RESERVEDGUESTS after the snippet above(2 lines)...

    I tried to use clone method, that returns an object, but i get an error that says,

    clone method is protected in Object class at java.lang....
    If this can be the other alternative, can you show me a sample code that implements a copying of object through clone? or just a URL?

    I tried this,

    Code:
    DataSetHandler dsh = (DataSetHandler)RESERVEDGUESTS.clone();
    The compiler says that CloneNotSupport edException must be handled(or put a try/catch block)

    Now, if that exception occurs, How can i reimplement my DataSetHandler to be able to support cloning of that object?

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #32
      I don't know what you're talking about (it doesn't make sense to me) but if you
      want your class to be cloneable it must implement the Cloneable interface and
      possibly make the clone() method public. Read the API documentation.

      kind regards,

      Jos

      Comment

      • sukatoa
        Contributor
        • Nov 2007
        • 539

        #33
        Originally posted by JosAH
        I don't know what you're talking about (it doesn't make sense to me) but if you
        want your class to be cloneable it must implement the Cloneable interface and
        possibly make the clone() method public. Read the API documentation.

        kind regards,

        Jos
        Ok, here is an example, ( I forcely assume that String is similar to DataSetHandler )

        [CODE=JAVA]
        String RESERVEDGUESTS = new String("I_am_wh o_am");
        String dsh = RESERVEDGUESTS;

        String[] st=dsh.split("_ ");
        dsh = "";
        for(String s:st){
        System.out.prin t(s+" ");
        dsh = dsh.concat(s+" ");
        }[/CODE]
        The code above is just to represent my problem....
        Suppose dsh was initialized by RESERVEDGUESTS,

        After the code
        Code:
        dsh = "";
        the RESERVEDGUESTS also equal to dsh, expected to be unchanged (obviously)... But as dsh is changing, the RESERVEDGUESTS also changing....

        Now, i guess when you try to print the content of the object RESERVEDGUESTS, it should still be "I_am_who_a m" right?

        But, it's not... just like i said, RESERVEDGUESTS is proportional to dsh...
        Now, when we try to print RESERVEDGUESTS, it will show "I am who am "

        I am just representing my problem on my own class, these should not, and must not happen to String....

        That's my problem yesterday.....
        Now, i have the solution, but needs to reconstruct a new DataSetHandler. ..
        Here is my solution,

        Code:
        DataSetHandler dsh = new DataSetHandler(22);
        for(Object key : RESERVEDGUESTS.getUniqueKeys()){
               dsh.addDataSet(key, RESERVEDGUESTS.getMembers(key));
        }
        But, it consumes 4 lines of code......

        So, for implementing Cloneable interface, i will try it at this moment Jos...
        Thanks for your reply....

        Comment

        • sukatoa
          Contributor
          • Nov 2007
          • 539

          #34
          I wonder why static boolean variable in a Dialog doesn't reset's its value in the next invocation....

          at first invoke,

          Code:
          static boolean val=false;
          val is false,

          after some calculations, assigning val to true then dispose,

          and then invoke that dialog again,

          val now sets to true, the initialization at member's field have now no effect at all...
          Other datatypes that are static members are resets except val....(or all static booleans)

          Why is it happening?
          Whenever i call System.gc() and System.runFinal ization() method
          still no effect... it sets on the previous value after some processes....

          initializing it with just private(declari ng it with non static), no problem....

          Am i forgot something here?

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #35
            Originally posted by sukatoa
            Am i forgot something here?
            Normally, i.e. when you don't take special precautions, after a class is loaded
            by a ClassLoader it will never be released from memory by a garbage collector
            anymore. A static variable is a member of the class so it will never be released
            nor re-initialized anymore.

            kind regards,

            Jos

            Comment

            • sukatoa
              Contributor
              • Nov 2007
              • 539

              #36
              Thanks for you reply Jos....

              Now, i have doubt what should i choose to be the primary info on a black-listed guests....

              Honestly, i never tried to live on a hotel before... even just a day....

              I know the other fields to be added, but, to be sure....

              Here are the infos from the current guests

              *Room Number
              *Complete Name
              *Additional Guests
              *Address
              *Company Address
              *Contacts: landline,mobile ,fax and email
              *Passport Info ( Passport number and Place of issue )
              *Guest's remarks
              Method of Payment:
              Cash,Cheque(Fro m company/walk-in guest),Credit Card
              If Credit Card --> Credit Card Number and Expiry Date...
              Credit Card Info can be modified only by the admin...
              (For security reasons and to protect the guests from hacking their CC)

              *Arrival and Departure Time

              Deposit, Discount and total Charges....
              *Registered by: On duty clerk...
              *Modified by: On duty clerk...

              There is a button (Add to black List) that will transfer/copy the whole data from current/reserved guests to black listed guests... but, i like to remove those unnecessary data... (if any)

              ergo, transfering those data that are necessary for investigations/future preferences etc....

              And to save allocated values on registers and memory...( Just practicing )

              Im not sure the other infos that i've choose to be added on black list....
              For those info that i've choosen to be added( * ), what should be removed? what should be added?

              I've searched through the web, but all i got is black listed IP addresses, and blogs, discussion... most of them sucks....

              Can you help me on this? ( Im very sorry for asking this kind of questions, well!!!obviousl y not related to programming )

              Comment

              • sukatoa
                Contributor
                • Nov 2007
                • 539

                #37
                What should setFocusable(bo olean literal) do on JButton?

                I was trying to do such that, the button can't be clicked, or any event that can fire that component yet still on its current GUI state(Enabled),
                But i still can clicked,tabbed, etc....

                I don't like the button to be disabled(My eyes can't accept) :)

                How can i reproduce that?

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #38
                  Originally posted by sukatoa
                  What should setFocusable(bo olean literal) do on JButton?

                  I was trying to do such that, the button can't be clicked, or any event that can fire that component yet still on its current GUI state(Enabled),
                  But i still can clicked,tabbed, etc....

                  I don't like the button to be disabled(My eyes can't accept) :)

                  How can i reproduce that?
                  Users find it very annoying when they click on a button and nothing happens;
                  especially when they don't see that the button *can't* be clicked. That's what
                  the disabled state is for. When users tab around and the button is focusable
                  they can tab to it and press 'space' to click it. That's what the focusable state
                  is for. Some text components also have an editable state; that doesn't apply
                  to a button though. Pick your choice.

                  kind regards,

                  Jos

                  Comment

                  • sukatoa
                    Contributor
                    • Nov 2007
                    • 539

                    #39
                    Originally posted by JosAH
                    Users find it very annoying when they click on a button and nothing happens;
                    especially when they don't see that the button *can't* be clicked. That's what
                    the disabled state is for. When users tab around and the button is focusable
                    they can tab to it and press 'space' to click it. That's what the focusable state
                    is for. Some text components also have an editable state; that doesn't apply
                    to a button though. Pick your choice.

                    kind regards,

                    Jos
                    Thank you very much for the information Jos, it did help me decide. :)

                    Thanks again...

                    Comment

                    • sukatoa
                      Contributor
                      • Nov 2007
                      • 539

                      #40
                      Project DONE....

                      I would like to thank JoshAH and r035198x for helping on my simple project.....
                      I learned something new from you guys.... :)

                      CHEERS,
                      Red Horse

                      Comment

                      • JosAH
                        Recognized Expert MVP
                        • Mar 2007
                        • 11453

                        #41
                        Originally posted by sukatoa
                        Project DONE....

                        I would like to thank JoshAH and r035198x for helping on my simple project.....
                        I learned something new from you guys.... :)

                        CHEERS,
                        Red Horse
                        Good; congrats. Did you deploy it already and did your friend like it?

                        kind regards,

                        Jos

                        Comment

                        • sukatoa
                          Contributor
                          • Nov 2007
                          • 539

                          #42
                          Originally posted by JosAH
                          Good; congrats. Did you deploy it already and did your friend like it?

                          kind regards,

                          Jos
                          Yah, i already send him the installer.... we we're communicating on YM last 7 or 8 hours as im still guiding him for the installation( i forgot to create a documentation about the installation guidelines).... ..

                          Successful..... and he like it... :)

                          Sad to think that, im developing that program over a month, and then he will just use that program for 3 days demo or a week(i think) in this semester.... hahahahhh :(

                          Most of the time ideas aren't bad, it's the implementations that are extremely bad.
                          That phrases are really inspiring(for me)....

                          Thanks again,
                          Cheers

                          Comment

                          Working...