Desperate for help - Java beginer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • carly
    New Member
    • Oct 2006
    • 37

    Desperate for help - Java beginer

    Hi,
    im new to java and i really need help with my assigment. I need a simple methode that will:

    1- allow a member of a Internet cafe to log in to the workstation

    2- log out of the workstation

    3- a methode to add a new member to the cafe.

    4- a methode to renew the membership

    This is my code:

    public class Member {

    String ID;
    double timeBalance;
    double creditBalance;
    String workstationID;
    Integer totalTime;
    Integer date;
    Integer discount;
    Integer loginTime;
    Integer logoutTime;
    String password;

    //parameterized constructor
    public Member(String ID, double timeBalance, double creditBalance, String
    workstationID, Integer totalTime, Integer date, Integer discount,
    Integer loginTime, Integer logoutTime, String password)
    {
    this.ID = ID;
    this.timeBalanc e = timeBalance;
    this.creditBala nce = creditBalance;
    this.workstatio nID = workstationID;
    this.totalTime = totalTime;
    this.date = date;
    this.discount = discount;
    this.loginTime = loginTime;
    this.logoutTime = logoutTime;
    this.password = password;
    }

    public String getID()
    {return ID;}

    public String getpassword()
    {return password;}

    public double gettimeBalance( )
    {return timeBalance;}

    public double getcreditBalanc e()
    {return creditBalance;}

    public String getworkstationI D()
    {return workstationID;}

    public Integer gettotalTime()
    {return totalTime;}

    public Integer getdate()
    {return date;}

    public Integer getdiscount()
    {return discount;}

    public Integer getloginTime()
    {return loginTime;}

    public Integer getlogoutTime()
    {return logoutTime;}


    public void setID(String ID)
    {this.ID= ID;}

    public void setpassword(Str ing password)
    { this.password = password;}


    public void settimeBalance( double timeBalance)
    {this.timeBalan ce= timeBalance;}

    public void setcreditBalanc e(double creditBalance)
    {this.creditBal ance = creditBalance;}

    public void setworkstationI D(String workstationID)
    {this.workstati onID = workstationID;}

    public void settotalTime(In teger totalTime)
    { this.totalTime = totalTime;}

    public void setdate (Integer date)
    { this.date = date;}

    public void setdiscount (Integer discount)
    {this.discount = discount;}

    public void setloginTime(In teger loginTime)
    {this.loginTime = loginTime;}

    public void setlogoutTime(I nteger logoutTime)
    { this.logoutTime = logoutTime;}



    //This function is like a log in which the info for the member is stored in.
    public void MemberInfo(Memb er m){
    System.out.prin tln("Member ID is " + m.ID);
    System.out.prin tln("Member time Balance is " + m.timeBalance);
    System.out.prin tln("Member credit Balance is " + m.creditBalance );
    System.out.prin tln("Member Workstation ID is " + m.workstationID );
    System.out.prin tln("Total time spent by the Member is " + m.totalTime);
    System.out.prin tln("Member log-in date is " + m.date);
    System.out.prin t("Member discount is " + m.discount);
    System.out.prin t("Member log-in time is " + m.loginTime);
    System.out.prin t("Member log-out time is " + m.logoutTime);
    System.out.prin t("Member password is " + m.password);
    System.out.prin tln("");
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by carly
    Hi,
    im new to java and i really need help with my assigment. I need a simple methode that will:

    1- allow a member of a Internet cafe to log in to the workstation

    2- log out of the workstation

    3- a methode to add a new member to the cafe.

    4- a methode to renew the membership

    This is my code:

    public class Member {

    String ID;
    double timeBalance;
    double creditBalance;
    String workstationID;
    Integer totalTime;
    Integer date;
    Integer discount;
    Integer loginTime;
    Integer logoutTime;
    String password;

    //parameterized constructor
    public Member(String ID, double timeBalance, double creditBalance, String
    workstationID, Integer totalTime, Integer date, Integer discount,
    Integer loginTime, Integer logoutTime, String password)
    {
    this.ID = ID;
    this.timeBalanc e = timeBalance;
    this.creditBala nce = creditBalance;
    this.workstatio nID = workstationID;
    this.totalTime = totalTime;
    this.date = date;
    this.discount = discount;
    this.loginTime = loginTime;
    this.logoutTime = logoutTime;
    this.password = password;
    }

    public String getID()
    {return ID;}

    public String getpassword()
    {return password;}

    public double gettimeBalance( )
    {return timeBalance;}

    public double getcreditBalanc e()
    {return creditBalance;}

    public String getworkstationI D()
    {return workstationID;}

    public Integer gettotalTime()
    {return totalTime;}

    public Integer getdate()
    {return date;}

    public Integer getdiscount()
    {return discount;}

    public Integer getloginTime()
    {return loginTime;}

    public Integer getlogoutTime()
    {return logoutTime;}


    public void setID(String ID)
    {this.ID= ID;}

    public void setpassword(Str ing password)
    { this.password = password;}


    public void settimeBalance( double timeBalance)
    {this.timeBalan ce= timeBalance;}

    public void setcreditBalanc e(double creditBalance)
    {this.creditBal ance = creditBalance;}

    public void setworkstationI D(String workstationID)
    {this.workstati onID = workstationID;}

    public void settotalTime(In teger totalTime)
    { this.totalTime = totalTime;}

    public void setdate (Integer date)
    { this.date = date;}

    public void setdiscount (Integer discount)
    {this.discount = discount;}

    public void setloginTime(In teger loginTime)
    {this.loginTime = loginTime;}

    public void setlogoutTime(I nteger logoutTime)
    { this.logoutTime = logoutTime;}



    //This function is like a log in which the info for the member is stored in.
    public void MemberInfo(Memb er m){
    System.out.prin tln("Member ID is " + m.ID);
    System.out.prin tln("Member time Balance is " + m.timeBalance);
    System.out.prin tln("Member credit Balance is " + m.creditBalance );
    System.out.prin tln("Member Workstation ID is " + m.workstationID );
    System.out.prin tln("Total time spent by the Member is " + m.totalTime);
    System.out.prin tln("Member log-in date is " + m.date);
    System.out.prin t("Member discount is " + m.discount);
    System.out.prin t("Member log-in time is " + m.loginTime);
    System.out.prin t("Member log-out time is " + m.logoutTime);
    System.out.prin t("Member password is " + m.password);
    System.out.prin tln("");
    }
    If you want the program to remember the members added to the cafe everytime th eprogram runs, you will need to store that information in a database. You now need to write the class which has a method for each of the tasks you want done above and also the main method which puts all these things in motion

    Comment

    • carly
      New Member
      • Oct 2006
      • 37

      #3
      Originally posted by r035198x
      If you want the program to remember the members added to the cafe everytime th eprogram runs, you will need to store that information in a database. You now need to write the class which has a method for each of the tasks you want done above and also the main method which puts all these things in motion
      Hi thank you so much for your help, but i dont need a class that does the tasks....... i need methodes for each of the tasks that i have mentioned for ex: how can i do the methode "login" and "logout"wic h allows the member of the cafe to log-in to the workstation and log-out of it? Bear in mind that login and logout are methodes that will be used in my class called "Member"

      Thanks and i really hope that you reply.

      takecare!!

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by carly
        Hi thank you so much for your help, but i dont need a class that does the tasks....... i need methodes for each of the tasks that i have mentioned for ex: how can i do the methode "login" and "logout"wic h allows the member of the cafe to log-in to the workstation and log-out of it? Bear in mind that login and logout are methodes that will be used in my class called "Member"

        Thanks and i really hope that you reply.

        takecare!!
        You still haven't said whether or not you are going to use a database. It changes the look of most of the methods you want written.

        Comment

        • carly
          New Member
          • Oct 2006
          • 37

          #5
          Hi............ thank you SOOOOO much for your help. No im not going to use a databse.

          thanks once again, hope to hear from you soon!

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by carly
            Hi............ thank you SOOOOO much for your help. No im not going to use a databse.

            thanks once again, hope to hear from you soon!
            Code:
            public Member logIN() {
            	Member member = null;
                            Scanner scan = new Scanner(System.in);
            	System.out.print("Enter Id:");
            	String id = scan.nextLine();
            	System.out.println("Password ");
            	String password = scan.nextLine();
            	Date loginTime = new Date();
            	
                            member = new Member();
            	member.setID(id);
            	member.setPassword(password);
            	member.setLogInTime(logInTime);
            	if(!isLogged(member)) {
                            }
                            else {
                              System.out.println("Already Logged");
                              member = null; 
                            }
                            return member;
            }
            public static void main(String[] args) {
            	List<Members> loggedMembers = new ArrayList<Members>;
            	List<Members> allMembers = new ArrayList<Members>;
                            Member m = logIn();
            	if(m != null) {
                                 members.add(m);
                                 if(isMember(m)) {
                                 }
                                 else {
                                      allMembers.add(m);
                                 }
                            }
                            
            
            }
            Here is something to get you started. If a member logs out, remove the member from the loggedMembers list.
            I still think you should use another class for this.

            Comment

            • carly
              New Member
              • Oct 2006
              • 37

              #7
              Hi, thank you so much r035198x, i will try your code and i'll try to do the logout methode...will let you know about my progress....... .THANKS!!

              carly

              Comment

              Working...