Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 24th, 2004, 04:22 AM
afterburner14 afterburner14 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 afterburner14 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
unable to display method properly

how do i display the total annual fee from the driver program?
i know something is missing from the Member class, but not sure what exactly
please help.

here is the Member.class

public class Member
{

private String memberName="";
private char memberType;
private double annualFee=0.0;
private int yearJoined=0;



public Member (String inMemberName, char inMemberType, int inYearJoined)
{
memberName=inMemberName;
memberType=inMemberType;
yearJoined=inYearJoined;

}

public String getMemberName()
{

return memberName;

}

public char getMemberType()
{

return memberType;

}

public double getAnnualFee()
{

return annualFee;

}



public int getYearJoined()
{

return yearJoined;

}

public void setMemberName(String inMemberName)
{

memberName=inMemberName;

}

public void setMemberType(char inMemberType)
{
memberType=inMemberType;

if (memberType=='s'||memberType=='S')
{
memberType='s';
annualFee=100;

}

else
{
memberType='p';
annualFee=500;
}



}

public void setYearJoined(int inYearJoined)
{

yearJoined=inYearJoined;

}

public String getMemberTypeString()
{
if (memberType=='s'||memberType=='S')

return ("Social");

else

return ("Playing");

}

public String toString()
{

return memberName + " ("+getMemberTypeString()+" member) joined in " +yearJoined;

}
}

Reply With Quote
  #2  
Old April 24th, 2004, 04:23 AM
afterburner14 afterburner14 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 afterburner14 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here is the GolfClub.class (not complete yet, just testing some of the functions first)

public class GolfClub
{
private final int SIZE=10;
private Member[] member;
private int count;


public GolfClub()
{
member= new Member[SIZE];
count=0;
}

public boolean add(Member membr)
{
if (count==SIZE)

return false;

member[count]=membr;
count++;
return true;
}

public String getAll()
{
String msg="Members : \n";
for (int i=0;i<count;i++)

msg+=member[i].toString() + "\n";

return msg;
}

public double total()
{
double sum=0.0;
for (int i=0;i<count;i++)

sum+=member[i].getAnnualFee();

return sum;
}

public String getAllMembers()
{
String msg="There are ";
return msg;
}
}

Reply With Quote
  #3  
Old April 24th, 2004, 04:24 AM
afterburner14 afterburner14 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 afterburner14 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
GolfClubClient.java

public class GolfClubClient
{
public static void main(String[]args)
{
Member mem=null;
GolfClub golfclub=new GolfClub();
String name="";
char choice;
char memtype;
int year;

do
{
choice=doMenu();
switch (choice)
{
case '1':

System.out.println();
System.out.print ("Name :");
name=SavitchIn.readLine();
System.out.print ("Member type - <P>Playing <S>Social :");
memtype=SavitchIn.readLineNonwhiteChar();
System.out.print ("Year joined :");
year=SavitchIn.readLineInt();
mem=new Member(name,memtype,year);

if(golfclub.add(mem))
{
System.out.println("Addition Success");
System.out.println();
}
else
{
System.out.println("Collection is full");
System.out.println();
}
break;

case '2':

System.out.println();
System.out.println (golfclub.getAll());
System.out.println();
break;

case '3':

System.out.println();
System.out.println (golfclub.total());
System.out.println();
break;
}
} while (choice!='0');
}


public static char doMenu()
{
System.out.println("Welcome to the Saujana GolfClub System");
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Please select from the following menu");
System.out.println("1 Register new member");
System.out.println("2 List all the details of members");
System.out.println("3 Print the total annual fee");
System.out.println("4 List a count of members by classification");
System.out.println("5 List all members who joined in a particular year");
System.out.println("6 List all members whose names contain a specific substring");
System.out.println("7 Delete a member from the collection");
System.out.println("8 Change details for a member, given the name");
System.out.println("9 List all details of member sorted in ascending of name");
System.out.println();
System.out.println("0 Exit");
System.out.println();
System.out.print("Your choice? ");
char ch = SavitchIn.readLineNonwhiteChar();
return ch;
}
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > unable to display method properly


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT