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 2 of 2

Thread: problem with an assignement: creating collections class and use them

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

    Default problem with an assignement: creating collections class and use them

    Well, in my java project , I need to create using netbeans a program similar to the Amazon website, well I post you the link so you can see all of it, it can help you: (c) CJoint.com, 2012

    Well I need to make a menu in which the user can register as a member, modify profile etc, browse for books and view their data,etc..
    Here is my code from the class Member:
    package amazonapplication;
    import java.util.Scanner;
    /**
     *This class describes a Member
     * @author 
     */
    public class Member {
        private String username;
        private String password;
       /**
        * 
        * @param user name as a string
        * @param pass password as a string
        */ 
        public Member(String user, String pass ){ 
            username=user;
           password=pass;
        }
     
        /**
         * Setter of Password
         * @param password the password to set
         */
        public void setPassword(String password){ 
           this.password=password;
        }
        /**
         * Setter of Username
         * @param username the username to set
         */
        public void setUsername(String username){
            this.username=username;
        }
        /**
         * Getter of Username
         * @return the username
         */
        public String getUsername(){ // get method for username
            return username;
        }
        /**
         * Getter of Password
         * @return the password
         */
        public String getPassword(){ // get method for password
            return password;
        }
        /**
         * Method used to change current password
         * @param password current password to change
         * @param newpass  new password to set
         * @return boolean change of password successful or not
         */
        public boolean changePass(String password, String newpass){
            if(this.getPassword().equals(password)){
                this.setPassword(newpass);
                    return (true);
            }
            else return (false);
        }
    /**
     * Method used to set new password if old one is lost/forgotten
     * @param username member's username
     * @param newpass memeber's new password
     * @return boolean: procedure successful or not 
     */
        public boolean forgotpass(String username, String newpass){
            if(this.username.equals(username)){
                this.setPassword(newpass);
                return (true);
     
            }
            else return (false);
     
        }
         /**
         * Method used to authenticate user
         * @param username name as string
         * @param password password as string
         * @return boolean: authentification successful or not
         */
        public void authenticate  (String username, String password)throws PassException{
            if(this.username.equals(username) && this.password.equals(password))
               System.out.println("Authentification Successful!");
     
            else throw new PassException ();
     
     
        }
        /**
         * Prints member information
         * @return String to print 
         */
        @Override
        public String toString(){
            return "username is:"+this.username+
                   "\npassword is:"+this.password;
        }
     
    }
    And here is my code the class MemberList(not complete yet, i don't know how to do save and load behaviors)
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package amazonapplication;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.ListIterator;
    /**
     *
     * @author
     */
    public class MemberList {
     
        List<Member> members;
        public MemberList(){
            this.members=new LinkedList<>();
        }
        public boolean addmember(Member memb){
            return members.add(memb);
        }
         public boolean removeMember(Member memb) {
            return members.remove(memb);
    }
     
    }
    Well now that I have coded those classes, I should use them for my main
    But I don't know how, in my main, I can manage when a user wants to register or do something else from the menu. Does it have a relation with associations ? Its said in my assignement: Finish the implementation of the class Member, a member has an association with OrderList.
    Well I am lost


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

    Default Re: problem with an assignement: creating collections class and use them

    No answer ?

Similar Threads

  1. [SOLVED] Help with creating a class and driver
    By JackCannon15 in forum Object Oriented Programming
    Replies: 1
    Last Post: October 27th, 2011, 03:50 PM
  2. Creating and implementing class for creating a calendar object
    By kumalh in forum Object Oriented Programming
    Replies: 3
    Last Post: July 29th, 2011, 08:40 AM
  3. [SOLVED] Creating A Class
    By cb5950 in forum Object Oriented Programming
    Replies: 1
    Last Post: March 31st, 2011, 07:27 AM
  4. [SOLVED] Class Creating Help
    By pitchblack in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 1st, 2011, 11:25 PM
  5. Help with creating a class
    By cdawg_2010 in forum Loops & Control Statements
    Replies: 4
    Last Post: November 1st, 2010, 07:04 AM