Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2008, 11:20 AM
Member
 
Join Date: Mar 2008
Posts: 8
valoyivd is on a distinguished road
return a null method
this is my method that returns a null but that is not a good thing to return coz my program will fail...what can I do to return a sum thing that will cause my program not to throw a nullpointer exception...here is my code
Code:
private MgCalcStrategy getStrategy() { if (isRetirementScheme && isAdminInclusive) { return MgCalcStrategy.RET_INCLUSIVE; } if (isRetirementScheme && !isAdminInclusive) { return MgCalcStrategy.RET_EXCLUSIVE; } if (isBothScheme && isAdminInclusive && isRiskInclusive) { return MgCalcStrategy.RISK_INC_ADMIN_INC; } if (isBothScheme && isAdminInclusive && !isRiskInclusive) { return MgCalcStrategy.RISK_INC_ADMIN_INC; } if (isBothScheme && !isAdminInclusive && isRiskInclusive) { return MgCalcStrategy.RISK_INC_ADMIN_EXC; } if (isBothScheme && !isAdminInclusive && !isRiskInclusive) { return MgCalcStrategy.RISK_EXC_ADMIN_EXC; } if (isRiskScheme) { return MgCalcStrategy.RISK_ONLY; } //TODO: Change this to return a null Strategy return null; }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-16-2008, 12:43 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
I guess your code must return an object....

Have a look at object class, take a comparison with null....

if satisfied, then block, else allow...

Correct me if im wrong,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-22-2008, 01:19 AM
Member
 
Join Date: Mar 2008
Posts: 8
valoyivd is on a distinguished road
Quote:
public enum MgCalcStrategy {

RET_INCLUSIVE {
public double getCost(MemberGroup mg,Quote quote) {
return mg.getEeContribPerc() + mg.getErContribPerc()/PERCENT_VALUE
* mg.getTotalAnnualSalary();
}
},


RISK_INC_ADMIN_EXC {
public double getCost(MemberGroup mg,Quote quote) {
return (mg.getEeContribPerc() + mg.getErContribPerc()
+ mg.getBenefitFam().getPercCost() + quote.getFinalInput().getAdminPerc()
+ quote.getFinalInput().getRenewalCommPerc())
/PERCENT_VALUE * mg.getTotalAnnualSalary();
}

},
RiskExcAdminInc {
public double getCost(MemberGroup mg,Quote quote) {
return mg.getEeContribPerc()+ mg.getErContribPerc() ;
}

},
RISK_EXC_ADMIN_EXC{
public double getCost(MemberGroup mg,Quote quote) {
return mg.getErContribPerc()+ mg.getEeContribPerc()+
quote.getFinalInput().getAdminPerc()+
quote.getFinalInput().getRenewalCommPerc()+
mg.getBenefitFam().getPercCost()/PERCENT_VALUE
* mg.getTotalAnnualSalary();
}

},
RiskOnly {
public double getCost(MemberGroup mg,Quote quote) {
return mg.getBenefitFam().getPercCost();
}

}, ;
public abstract double getCost(MemberGroup mg,Quote quote);
private static final double PERCENT_VALUE = 100.0;

}
just don't know how am I gona implement the null strategy...here is the completing code of what I have ...please help me
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
return Set .toArray(); method as an array of integers maxim New To Java 2 04-16-2008 02:35 PM
Return question in a method. MetalGear New To Java 1 01-13-2008 06:45 AM
if..else..return mqdias New To Java 1 08-10-2007 06:20 PM
Return value of method cachi New To Java 1 08-01-2007 10:23 AM
Error: invalid method declaration; return type required silvia AWT / Swing 1 07-19-2007 03:51 PM


All times are GMT +3. The time now is 06:17 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org