Results 1 to 20 of 20
  1. #1
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default Masking passwords & booking movies

    HELLO HERE I AM AGAIN!

    Alright so for the next part of my current assignment is another headache. I'm supposed to do an online movie booking system. And of course, my program design sucks very badly as I'm not too sure on how to create the classes. If there is someone willing enough to push me to the right track, I would appreciate it.

    Firstly, there are 3 types of movie members, normal, silver and gold. Then there's a movie class which holds all the movie titles and all that, in the movies there is halls which showcases different movies and such, but let's just leave it that my movies class only makes the movies. And one main cinema class which runs the whole thing.

    So my methods would be right now is just .bookMovie(). And there I'm a little confused, how am I supposed to let my users book their movie in their own account? Because the member's class is not extended to movie, it is a different and has no relation. So I could need some help with this.

    So then, there's this feature that I would also like to do which is to mask the user's passwords. I did research that I could do: text.setEchoChar("*").

    But I'm not so familiar. I could need some help with designing my movie booking program! Thanks!

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    What you've tried so far? Can you show your effort here?

    First of all design your application properly, by stepping down the final goal. Decide how many classes you want to handle this, what are the information you required to process, how the information passing, possibilities for future improvements, etc..

  3. #3
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default

    Alright, I've decided to design my program bit by bit. Currently, I have a problem with the password things. So like, if you enter the wrong password, the problem should let you reenter at a limit of tries, however, right now my code doesn't does the check except keep looping over and over.

    Java Code:
    			else if (choice == 4) {
    				System.out.println("Entering Booking System. ");
    				System.out.println("Please enter member login. ");
    				System.out.println("Please enter member ID: ");
    				int search = scan.nextInt();
    				
    				for (Members checkID: Member) {
    					if (checkID.getID() == search) {
    						System.out.println("Please enter password (Case sensivite): ");
    						scan.nextLine();
    						String pass = scan.nextLine();
    						
    						for (Members checkPass : Member) {
    							if (checkPass.getPass().equals(pass)) {
    								System.out.println("Password matched.");
    								break;
    							}
    					
    							else if (!checkPass.getPass().equals(pass)) {
    								System.out.println("Please reenter password: ");
    								pass = scan.nextLine();
    							}
    						}
    							
    					}
    				}
    				
    			}
    Also, how do you make a relationship between two classes that have no relation to each other? Like if a movie goer wants to book a movie, I can't have my movie class extend the member class, so what can I do to let my movie user book a movie which is in another class?

  4. #4
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    have you heard of a while loop?

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  6. #6
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default

    My while loop is at the very top that compacts all of my other choices together, but iI suppose using another one might work. Anyways, prior to my question at the bottom of my codes.

    I'm asking how might I let my user book a movie from the movie class? Right now I can't think of how I'm going to do that, but I do get the idea that it might be using the ArrayList<>. However, I would like some expert opinion on getting my user to book a movie. Both classes are not extended and are standalone with one main. Any suggestions?

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by suneko View Post
    I'm asking how might I let my user book a movie from the movie class? Right now I can't think of how I'm going to do that, but I do get the idea that it might be using the ArrayList<>. However, I would like some expert opinion on getting my user to book a movie. Both classes are not extended and are standalone with one main. Any suggestions?
    What your movie class suppose to do, what are the information you want to pass within?

  8. #8
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default

    Well, I've decided to make another class called Tickets.

    Movies fields:
    title
    ID
    time

    that's all. So I guess I will be using an Array to compare with the other arrays, I'll see how it goes. Thanks for trying to help.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Do you have a design about this, can you bit explain. Actually changing the application based on your difficulties found on the way is not good, upto some extend is fine. You must have a proper design at the begging, even not it completely decide up to some extend at least.

  10. #10
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default

    Alright this is my design right now.

    Member class
    Movie class
    Ticket class

    Member fields:
    name, id, password
    methods:
    getname(), getID()

    Movie fields:
    title, id, time
    methods:
    getTitle(), getmovieID(), getTime()

    Tickets fields:
    tictotal, id, name
    methods:
    getTicketTotal(), getbookedID(), getbookedName()

    In my main is where all the workings are happening, like what happens if you choose this choice and the like. I've got some logic error in my codes one that's logging in the member's password and the like. Can't really figure it out, since my braces seem right. :(

  11. #11
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    getTime() as a method of the class Movie is breaking Movies abstraction, it should not be there, when making methods always ask yourself the question does a movie "have a..."

    For e.g. does a movie have a Title, yes. Does a movie have a time? no.

    If you want to let a user book a movie, why not make a Booking class with say a method called:

    Java Code:
    bookAMovie(Movie theMovie, Member theMember, Ticket memberTicket, Time timeOfBooking){
    // insert the necessary here
    
    }
    Make a Time class to handle times

  12. #12
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default

    Oh?! Constructors can call other exterior classes and use their variables? I didn't know that. :D

    But then I actually don't understand the...

    Java Code:
    bookAMovie([B]Movie theMovie, Member theMember, Ticket memberTicket, Time timeOfBooking[/B])
    What's it doing?
    Last edited by suneko; 07-17-2010 at 05:11 PM.

  13. #13
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Constuctors can be passed exterior class variables e.g.

    Java Code:
    public myConstructor(Movie theMovie){
    
    theMovie=new Movie();
    }
    Do more reading on the fundamentals of classes

  14. #14
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    public myConstructor(Movie theMovie){

    theMovie=new Movie();
    }
    Why do that? The new object's reference goes out of scope on exit from the method.
    Remember pass by value.

  15. #15
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default

    Actually, I tried doing that, but it gave me no new sense of breakthrough, so I won't be using it in my codes or perhaps that I will, I will have to talk to my facilitator tomorrow in the morning to see what went wrong and how I can improve my codes.

    I tried using the contructor and calling exterior classes but it gave me more trouble than I could figure it out though. Thanks for suggesting. Are there other ways of which can help my user book movies?

  16. #16
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default

    Okay, I've managed to do as much as I can, although I'm not pretty sure how do you print out values within a value of a values in a vector?

    I have this theatre vector which holds, showPrices vector which holds all the variables of my movie prices. Can I have some help?

  17. #17
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    how do you print out values within a value of a values in a vector?
    Can you explain what that means?
    Show an example of what the print out should look like? And explain where the info to print comes from.

    Does some of the info to print come from the theatre vector and some come from the showPrices vector?

  18. #18
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Quote Originally Posted by Norm View Post
    Why do that? The new object's reference goes out of scope on exit from the method.
    Remember pass by value.
    You are right I should have declared a private or protected Movie theMovie with full scope before hand and assigned that to the Movie passed as an argument in the constructor

  19. #19
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Can you post what you have now? would help out alot.

  20. #20
    suneko is offline Member
    Join Date
    May 2010
    Posts
    19
    Rep Power
    0

    Default Solved

    Ahah. It's alright. Everything is done and said and finished. :D

    Just had to do a .get(i) lol.

Similar Threads

  1. Masking a credit card value
    By Samurai Coder in forum New To Java
    Replies: 2
    Last Post: 12-02-2009, 09:05 PM
  2. Masking password for logging
    By firewalll in forum New To Java
    Replies: 1
    Last Post: 09-29-2009, 08:04 AM
  3. Watch TV on PC - 12,000 TV Channels and Movies, save money Get $10 rebate.
    By arturmoniswork in forum Reviews / Advertising
    Replies: 0
    Last Post: 12-30-2008, 05:56 AM
  4. Taking passwords on the console
    By eva in forum Advanced Java
    Replies: 2
    Last Post: 12-19-2007, 09:28 AM
  5. Replies: 0
    Last Post: 12-15-2007, 08:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •