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:
And here is my code the class MemberList(not complete yet, i don't know how to do save and load behaviors)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; } }
Well now that I have coded those classes, I should use them for my main/* * 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); } }
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