• Post Reply Bookmark Topic Watch Topic
  • New Topic

Final project help  RSS feed

 
karol siwik
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.  I'm working on my final project that requires a zoo authentication system with two classes.  Initially, the program is supposed to ask for options to log in or log out.  If a user enters a correct username and password (has to be read from a credentials text file and convert the password using MD5 hash), then the program will print out that user's zoo role file (I.e. admin will print "welcome admin, you have access to...").  The role also gets read from a text file and printed to the screen.  If a user enters an incorrect password 3 times, the program will exit. 

I'm using my second class for different methods for the files.  For example, one method will read the credentials text, another method will read the role text, and third method to convert the password to the MD5 hash.

So far, I just have printed to the main for options 1 and 2 to log in or log out.  Now, I'm working on if the correct username/pw gets entered that it will continue with the program.  I'm having issues reading the credentials from the second class method into the main program.  Here is my code so far:

Any help would be greatly appreciated.



 
Pete Letkeman
Ranch Foreman
Posts: 900
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two quick things:
  • Are you able to provide the contents on the text file? Or maybe a sample?
  • I'm not so sure that you should hard code the location of the text file. I'm fairly certain that there are ways to get the file location inside of your program
  •  
    karol siwik
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes.  The contents are:
    credentials.txt:
    griffin.keyes 108de81c31bf9c622f76876b74e9285f "alphabet soup" zookeeper
    rosario.dawson 3e34baa4ee2ff767af8c120a496742b5 "animal doctor" admin
    bernie.gorilla a584efafa8f9ea7fe5cf18442f32b07b "secret password" veterinarian
    donald.monkey 17b1b7d8a706696ed220bc414f729ad3 "M0nk3y business" zookeeper
    jerome.grizzlybear 3adea92111e6307f8f2aae4721e77900 "grizzly1234" veterinarian
    bruce.grizzlybear 0d107d09f5bbe40cade3de5c71e9e9b7 "letmein" admin

    zookeeper.txt:
    Hello, Zookeeper!

    As zookeeper, you have access to all of the animals information and their daily monitoring logs.  This allows you to track their feeding habits, habitat conditions, and general welfare.

    veterinarian.txt:
    Hello, Veterinarian!

    As veterinarian, you have access to all of the animals' health records.  This allows you to view each animal's medical history, current treatments/illnesses (if any), and maintain a vaccination log.

    admin.txt:
    Hello, System Admin!

    As administrator, you have access to the zoo's main computer system.  This allows you to monitor users in the system and their roles.

     
    Pete Letkeman
    Ranch Foreman
    Posts: 900
    26
    Android Chrome IntelliJ IDE Java MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Initial issues:
    This block of code:

    What variable are you assigning to the provided username?
    What variable are you assigning to the password?

    This line of code could just be a typo:

    but it does not compile. This does compile

    It's probably not what you want, but it does get you closer to what you want
     
    Pete Letkeman
    Ranch Foreman
    Posts: 900
    26
    Android Chrome IntelliJ IDE Java MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Please do not swallow the exception meaning instead of
    use
    If you swallow the exception then you when an unknown exception occurs it will be treated as file not found exception with your exception block.
    However if you define the exception you think may happen then you can deal with each one properly.

    You have a method named readFile(), which is not being called/used anywhere.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!