Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 21 of 21

Thread: Some help with an assignment based on crc cards

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Some help with an assignment based on crc cards

    Hi I need to make a program to implement classes for the amazon website with crc cards provided. I have to implement the basic classes for the website(Book, Profile, Member, RecallItem, BookItem, Review, Statistics, Order, Event). The first question for implementing classes says: Classes should show attributes, at least one constructor, getters, setters, toString() behavior that returns a String representation of the state of an object

    How can I know weither my class attributes and methods are static, private or another access level? And for the constructor, what should it take or return as arguments ? What does getters and setters mean?
    For the toString() behavior shlould I implement it in each class so that i can use it after to show the state of the objects ?

    Please I really need help, I a just starting java and my level is not good, and this assignement is due in 2 days
    Thanks


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    How can I know weither my class attributes and methods are static, private or another access level?
    attributes are almost always private, occasionally protected and rarely public. Make them private.
    getters and setters are almost always public.

    And for the constructor, what should it take or return as arguments ?
    uh oh, you'd better read up on constructors again. This is a non-question -- read your book or tutorial and you'll see why.

    What does getters and setters mean?
    Again, your book or tutorial or Google will answer this in a heart beat. Also look up accessor and mutator methods if you want to search on the formal term. We're not a substitute for looking at your text or tutorial, but if anything in your book or tutorial's explanation confuses you, please ask for clarification.

    For the toString() behavior shlould I implement it in each class so that i can use it after to show the state of the objects ?
    As for behavior, there is only one -- return a String. As for how to show the state of the object -- have it return the values held by your non-static class fields.

    Please I really need help, I a just starting java and my level is not good, and this assignement is due in 2 days
    Thanks
    Best advice: keep studying! Also, avoid posting due dates since that's not really a concern of ours. Good luck!
    Last edited by curmudgeon; October 5th, 2012 at 09:06 PM.

  3. #3
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Ok I am starting my code now, and If I don't know how to do smthing, I will let you know ok ?

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    Ok I am starting my code now, and If I don't know how to do smthing, I will let you know ok ?
    That sounds like a good plan. Again, good luck!

  5. #5
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Hey Curmudgeon, so far I made the code for the main class inside AmazonApplication class
    amazonapp.jpg
    But now that i am creating my other classes and trying to implment them, for example, for the class Member, I put the attributes ( which are btw Username and Password) but I need to implement 3 methods for this class: changepass(), authenticate() and forgotpass(), and I really don't know how I am going to code them :/

  6. #6
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    The code for the methods will all depend on the behaviors that these methods should have. So I think you'll need to tell and show more for us to better understand the problem and be able to help you.

  7. #7
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Well I am giving the full assignement so that you can better understand the problem
    http://cjoint.com/?BJgoTevrNuv

  8. #8
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    If you're going to post information, post it as text here in the forum, not as a link.

  9. #9
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Actually there is an array, that can't be posted as text, the link doesnt work?

  10. #10
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    Actually there is an array, that can't be posted as text, the link doesnt work?
    The link is flagged by my anti-virus as being malicious. Regardless,
    • all links carry the risk for being malicious, and many here won't click on them for that reason.
    • You're the one asking help from volunteers, and so it is your responsibility to make it easy for others to help you, including posting the pertinent information and text in the forum. That's not asking too much for free help, I don't think.

  11. #11
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Well I am sorry if you considered it as disrespect, here is the text:

    Your attachments should have the following format:
    <StudentName>_hwk<Number>.zip or rar
    Homework submitted by email will be discarded.
    Failure to abide the rules above would considerably lower your grade.
    Requirements
    Your task is to modify amazon.com in the following way:
    1. Implement the basic classes needed for this website (Book, Profile, Member, RecallItem, BookItem, Review, Statistics, Order, Event).
    To simplify we will make the following assumptions:
    „Ļ No aggregations needed for this homework (anything in yellow need not be implemented for now).
    2. Implement AmazonApplication class that creates few objects corresponding to classes in (1), calls their methods and displays their state.
    3. Identify packages and organize the classes in question (1) under these packages.
    4. Write and generate java documentation (javadoc) for the different classes in question (1).
    5. Implement and use at least one enumerated type.
    6. Define and handle at least 2 exceptional events using java exceptions.
    7. Have interaction with the user at the level of AmazonApplication using java.util.Scanner
    What to submit
    A zip file that contains the netbeans directory for your project (should contain src folder,
    dist/javadocdoc folder and dist/amazon.jar file)
    N.B. you should be able to run the jar file from the command line using:
    java ”Vjar amazon.jar
    Grading
    1. Packages (5 pts)
    2. Classes (55 pts)
    a. Classes should show attributes, at least one constructor, getters, setters, toString() behavior that returns a String representation of the state of an object
    2
    b. If you need a date or timestamp object, use java.util.Date or java.util.GregorianCalendar
    3. Enumerated type (5 pts), it should make sense an enumerated data type
    4. Exceptions (10 pts), 5 each, cannot be RuntimeException, not caught in the same place where it is thrown.
    5. Test application: AmazonApplication (10 pts).
    6. Java documentation (15 pts, graded based on quality of comments basically, html files should be found in the folder called javadocdoc).

    Then, we have the crc cards for the amazon website with the basic classes that are: Book, Profile, Member, RecallItem, BookItem, Review, Statistics, Order, Event. The class member has a 1..1 association with Profile class pr the following attributes and behaviors:
    Username
    Password
    changePass()
    authenticate()
    forgotPass()
    modify_profile()
    Another class such as Book has association 1..1 with Statistics class and has only behaviors:
    ISBN
    Authors
    Title
    Description/summary
    Selling unit price
    Table of contents
    Keywords
    category

    I hope you get it now ( I out only some classes, it would be too long otherwise)

    Thanks for your time

  12. #12
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    Well I am sorry if you considered it as disrespect, here is the text:
    Not so much disrespect, but rather not posting this will greatly decrease your chances of getting help.

    OK, regarding the methods,
    changePass()
    authenticate()
    forgotPass()

    What do you think that these methods should do? What will their behaviors need to be?

  13. #13
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Well as their names say they should change the pass fot the changepass() and for authenticate, check weither the password and the username are correct, for the forgotpass(), we have to let the user enter a new pass in case he forgot it. What do u mean by what will their behaviors need to be ? They are already behaviors or methods no?

    For the changepass(), I am think of this:

    public String changepass(String pPassword) {
    Scanner input= new Scanner(System.in);
    System.out.print("Enter your new password please:");
    String string= input.nextLine();
    return string;
    }
    I am not sure, I think I should remove the argument of the method

  14. #14
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    Well as their names say they should change the pass fot the changepass() and for authenticate, check weither the password and the username are correct, for the forgotpass(), we have to let the user enter a new pass in case he forgot it. What do u mean by what will their behaviors need to be ? They are already behaviors or methods no?
    Methods have certain behaviors. For instance, changePass will accept a String (for a weak password program) and use that String to change the password property -- that's its behavior.

    For the changepass(), I am think of this:

    public String changepass(String pPassword) {
    Scanner input= new Scanner(System.in);
    System.out.print("Enter your new password please:");
    String string= input.nextLine();
    return string;
    }
    No, I think you're over-thinking this method. It should have no user interaction and should return nothing, but rather should be as simple as possible -- you pass in a String, and it uses that String to change or set the password, simple as that. Get rid of return statements, get rid of use of Scanner, and use the parameter String passed in.

  15. #15
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Yeah but normally when we want to change or password, we are always asked what is our new one etc.., so there should be an interaction with the user no? he is the one who chooses his password after all. How about this ( following what you told me):
    public void changepass(String pPassword) {
    password= pPassword;
    }

    I am really not sure about it

  16. #16
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    Yeah but normally when we want to change or password, we are always asked what is our new one etc.., so there should be an interaction with the user no?
    Yes, but this is not the Profile class's responsibility. All Profile is responsible for is holding the state of the user's profile and having simple methods -- getter and setter methods and whatnot for changing the state. The user interaction occurs in code elsewhere. Think of it this way -- you want to be able to use the Profile class in a simple console application like you're creating, but you also want to later be able to use it in a GUI. If you tie the UI (user interface) too closely with the "model" class (i.e., Profile) you will greatly limit where and how it can be used. This is one of the key advantages to modularizing your program, to keeping different concepts in different classes.

    How about this ( following what you told me):
    public void changepass(String pPassword) {
    password= pPassword;
    }

    I am really not sure about it
    No, this is *much* better.

  17. #17
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Ok, can you help concerning the authenticate and forgotpass methods please ? I have only few hours left to finish and I still have lot to do :/

  18. #18
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    Ok, can you help concerning the authenticate and forgotpass methods please ? I have only few hours left to finish and I still have lot to do :/
    We all can help, but you'll need to show us your attempts first, same as before.

  19. #19
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    For the forgotpass() behavior , yout told me before that I should not put scanner or ask the user, so how can he enter the new password he wants to have ?

    I tought about this
    public void forgotpass(String pPassword){
    password= pPassword;
    System.out.println("Your new password is:"+password);
    }

    It's like the changepass()

    }

  20. #20
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Some help with an assignment based on crc cards

    Quote Originally Posted by hiepa View Post
    For the forgotpass() behavior , yout told me before that I should not put scanner or ask the user, so how can he enter the new password he wants to have ?

    I tought about this
    public void forgotpass(String pPassword){
    password= pPassword;
    System.out.println("Your new password is:"+password);
    }

    It's like the changepass()

    }
    That's a tough one and goes against what I stated previously. If this were my program, I wouldn't have this method, but instead would have alternative Strings that the user could enter in to retrieve their password such as the name of the first pet, their first grade teacher, ...

    But regardless, looks like you'll need to use a Scanner object inside of the method for this one. :-(

  21. #21
    Member
    Join Date
    Oct 2012
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some help with an assignment based on crc cards

    Well submitted the assignement unfinished, I will try to finish it.
    I have another question, suppose we have two classes, an Event class and a User class, how can we show the association between User and his event?
    Registered users can look for events, add information, etc

Similar Threads

  1. 64 Java Cheat Sheets(Ref cards)
    By saggammahesh in forum Java Programming Tutorials
    Replies: 2
    Last Post: May 1st, 2012, 08:42 AM
  2. Need help with Deck of Cards
    By yanksin1st in forum Java Theory & Questions
    Replies: 1
    Last Post: March 1st, 2012, 01:28 PM
  3. A deck of cards
    By glebovg in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 1st, 2012, 09:46 AM
  4. Adding cards back into deck
    By sp4ce in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 15th, 2011, 01:21 AM
  5. Sorting a deck of cards by suite or rank.
    By coyne20 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 13th, 2010, 08:47 AM