473,804 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Desperate for help - Java beginer

37 New Member
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("");
}
Oct 25 '06 #1
6 1733
r035198x
13,262 MVP
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
Oct 26 '06 #2
carly
37 New Member
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!!
Oct 26 '06 #3
r035198x
13,262 MVP
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.
Oct 26 '06 #4
carly
37 New Member
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!
Oct 26 '06 #5
r035198x
13,262 MVP
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!
Expand|Select|Wrap|Line Numbers
  1. public Member logIN() {
  2.     Member member = null;
  3.                 Scanner scan = new Scanner(System.in);
  4.     System.out.print("Enter Id:");
  5.     String id = scan.nextLine();
  6.     System.out.println("Password ");
  7.     String password = scan.nextLine();
  8.     Date loginTime = new Date();
  9.  
  10.                 member = new Member();
  11.     member.setID(id);
  12.     member.setPassword(password);
  13.     member.setLogInTime(logInTime);
  14.     if(!isLogged(member)) {
  15.                 }
  16.                 else {
  17.                   System.out.println("Already Logged");
  18.                   member = null; 
  19.                 }
  20.                 return member;
  21. }
  22. public static void main(String[] args) {
  23.     List<Members> loggedMembers = new ArrayList<Members>;
  24.     List<Members> allMembers = new ArrayList<Members>;
  25.                 Member m = logIn();
  26.     if(m != null) {
  27.                      members.add(m);
  28.                      if(isMember(m)) {
  29.                      }
  30.                      else {
  31.                           allMembers.add(m);
  32.                      }
  33.                 }
  34.  
  35.  
  36. }
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.
Oct 27 '06 #6
carly
37 New Member
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
Oct 27 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2587
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as I could not configure Apache myself. The REAL problem is that PHPmyAdmin works and sees my test database Wines.... But my PHP program does not!
5
1794
by: Tank | last post by:
I have had this post up here when i was trying to figure out how to make leading zeros and have been able to fudge that to work. I am now have trouble getting the loop that makes the folders to start fresh after the .jpg section of the move images code. this will be essential to make the whole thing work. Please help. Even if you just write out the solution. I am beggin. I am desperate. Please help. <!DOCTYPE HTML PUBLIC...
24
2155
by: Ministry Of Jute | last post by:
I returned home from work today to find an Airborne Express Letter Express mailer leaning up against my apartment door. The return addressee was Microsoft Suite 300 1165 Eastlake Avenue E Seattle, WA 98109
1
1716
by: Sajid | last post by:
Hello! Experts, I have the following piece of code in VB.NET that I want to use to update any records in the database. I would like to use a code as well as DataGrid to update the records. Please guide me how can I achieve it. I know there is an Update command to to do this that but since I am a newbie I don't know how? I'll be really grateful to those who may help me buy modifying the following code. I am really desperately looking for...
1
1557
by: itsjyotika | last post by:
Hello Everyone, I need to read data from a CVS file(i created it from micosoft excel) and then need to match it with the one of the date from the command line.If the date is there then it should say yes or else it should say no. I am not getting how to do this as i am just a beginer in perl. Can anybody help me in writting the code. the files r toooo.. big to be attached , so i have just shown a tiny portion of it. thanks in advance, rimjim...
1
1249
by: hamed steph | last post by:
i'm a beginer in programing and i need very much your help .i need explanation about while statement (loop initialization and structure of while ) also qualifier (long,short,unsigned ,signed,) type of variable (character and double). think you.......
3
2410
by: Dameon99 | last post by:
Hi.. Im experiencing a weird error I dont know how to fix. I have a scanner object and whenever I use nextInt, anything above 3 causes the program to crash saying and links me to this line of the class: (one I added all the asteriss to. // If we are at the end of input then NoSuchElement; // If there is still input left then InputMismatch private void throwFor() { skipped = false; if ((sourceClosed) &&...
0
1228
by: yjh0914 | last post by:
hi guys! so im basically editting my post i made earlier as it wznt as specific.. i have to make a program that basically ranks students by their cumulative gpa. the student's info is on a csv file written in a format like this, "name,bday,sex,9-1,9-2,10-1,10-2.....,cumulative". my question is, should i read this whole line nd jz use the cumulative data (im not sure how to do dat:/) or make a separate class nd make an array (for loop nd stuff)...
4
1266
by: kingmathyou | last post by:
I have been trying to figure it out this program for the passed two hours with no luck. It is probably very easy, but I can't figure it out. Here is what I have to do: Write a program that asks the user to enter name and score of students via a dialog box. Output the number of students, their names, and if their grade is above (or equal to) the average scores. • User may enter information about any number of students. • The user must...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.