public class Gym
{
private String membershipNumber;
private String memberName;
private String memberPostCode;
private String gymFee;
public Gym(String number, String name, String postCode, String fee)
{
setMembershipNumber(number);
setMemberName(name);
setPostCode(postCode);
setFee(fee);
}
/*I declared all the objects as private because the Constructor itself accepsts
*arguments and pass it to each methods parameter
*/
//set the membership number of a member as String
private void setMembershipNumber(String number)
{
membershipNumber = number;
}
//sets the name of the member as String
private void setMemberName(String name)
{
memberName = name;
}
//sets the post code as String
private void setPostCode(String postCode)
{
memberPostCode = postCode;
}
//sets the fee as String
private void setFee(String fee)
{
gymFee = fee;
}
//return methods here
private String getMemberNumber( )
{
return membershipNumber;
}
private String getMemberName( )
{
return memberName;
}
private String getPostCode( )
{
return memberPostCode;
}
private String getFee( )
{
return gymFee;
}
/* A method displayOutput,just in case the user wants to use all the
*return methods in just one call
*/
public void displayOutput( )
{
System.out.println("Number: " + getMemberNumber( ) + "\n" +
("Name: " + getMemberName( ) + "\n" +
("Post Code: " + getPostCode( ) + "\n" +
("Fee: " + getFee( )))));
}
/*Main program
*/
public class GymMembers
{
public static void main(String[] args)
{
Gym gymMembership1 = new Gym("129983", "Parvez", "1490", "50.00");
Gym gymMembership2 = new Gym("324512", "Mdx", "00013", "40.00");
gymMembership1.displayOutput( );
System.out.println("\n");
gymMembership2.displayOutput( );
System.exit(0);
}
}
}