Hey all. I am having some problems in my project work. I am trying to this 'transaction' class in which the user enters his personal details.Now all I want to do is that when I create a new account for the user, I must also know the date when the account was created so that if the account expiry after for eg. 3 months I issue this reminder. I think this has to do with the gregorian calander, but I don't Know how to even tackle it. Thanks dudes. Here is my code.
import java.io.*; // required for handling the IOExceptions
import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
class Transactions
{
// create an empty list to hold Cars
ArrayList<GymUser> UserListIn = new ArrayList<GymUser>();
public Transactions (ArrayList<GymUser> Tran)
{
UserListIn = Tran;
}
static void addTransaction(ArrayList<User> UserListIn)
{
String tempMemberShipID;
String tempName;
String tempSurname;
String tempAge;
String tempAddress;
String tempPhone;
String tempDuration;
String tempFrom;
String tempTo;
String tempTypeOfMembership;
Scanner keyboard = new Scanner(System.in);
keyboard.useDelimiter("\n");
System.out.println("Please enter the member's Personal Details to process Transaction");
System.out.println("----------------------------------------------------------------- ");
System.out.println("Enter the membership number");
tempMemberShipID = keyboard.next();
System.out.print("Enter Name: ");
tempName = keyboard.next();
System.out.print("Enter Surname:");
tempSurname = keyboard.next();
System.out.print("Enter Address:");
tempAddress = keyboard.next();
System.out.print("Enter Age:");
tempAge = keyboard.next();
System.out.print("Enter Phone:");
tempPhone = keyboard.next();
System.out.print("Type of membership:");
tempTypeOfMembership = keyboard.next();
System.out.print("Membership Duration:");
tempDuration = keyboard.next();
System.out.print("From:");
tempFrom = keyboard.next();
System.out.print("To:");
tempTo = keyboard.next();
//adding in array list.
UserListIn.add(new User(tempMemberShipID, tempName, tempSurname, tempAddress, tempPhone, tempAge,tempTypeOfMembership,tempDuration,tempFrom,tempTo));
}
//Now this is the class that contains constructor and methods.
import java.io.*;
public class User implements Serializable
{
//these are instance variables
private String m_UserrID;
private String m_UserName;
private String m_UserID;
private String m_UserSurname;
private String m_UserAddress;
private String m_UserPhone;
private String m_UserAge;
private String m_UserType;
private String m_UserDuration;
private static String m_UserFrom;
private String m_UserTo;
//this is the constructor
public User(String UserrID,String UserName,String UserSurname, String UserAddress, String UserPhone, String UserAge,String UserType,String UserDuration,String UserFrom,String UserTo)
{
m_UserrID = UserrID;
m_UserName = UserName;
m_UserSurname = UserSurname;
m_UserAddress = UserAddress;
m_UserPhone = UserPhone;
m_UserAge= UserAge;
m_UserType = UserType;
m_UserDuration = UserDuration;
m_UserFrom = UserFrom;
m_UserTo = UserTo;
}
public String getM_ID()
{
return m_UserrID;
}
// method to get the membership duration
public String getDuration()
{
return m_UserDuration;
}
// method to get the name
public String getName()
{
return m_UserName;
}
//method to set name
public void setName(String UserName)
{
m_UserName = UserName;
}
//method to return age
public String getAge()
{
return m_UserAge;
}
//method to set age
public void setAge(String UserAge)
{
m_UserAge =UserAge;
}
//method to return address
public String getAddress()
{
return m_UserAddress;
}
//method to set address
public void setAddress(String UserAddress)
{
m_UserAddress= UserAddress;
}
//method to return phone
public String getPhone()
{
return m_UserPhone;
}
//method to set phone
public void setPhone(String UserPhone)
{
m_UserPhone = UserPhone;
}
//method to return suname
public String getSurname()
{
return m_UserSurname;
}
//method to set surname
public void setSurname(String UserSurname)
{
m_UserSurname = UserSurname;
}
//method to get name
public String getID()
{
return m_UserID;
}
public String getType()
{
return m_UserType;
}
public static String getFrom()
{
return m_UserFrom;
}
public String getTo()
{
return m_UserTo;
}
}