-
make my code more efficient
Hi,
I coded an application and in the application I have this code:
Code:
public void testAtHighHealthRisk(HealthRiskCalculator calc) {
System.out.println("\nTesting atHighHealthRisk");
// TODO: replace the following line with testing of calc.atHighHealthRisk( )
//System.out.println("no testing yet.");
System.out.println(calc.atHighHealthRisk(26, 60));
}
public void testAtMediumHealthRisk(HealthRiskCalculator calc) {
System.out.println("\nTesting atMediumHealthRisk");
// TODO: replace the following line with testing of calc.atMediumHealthRisk( )
//System.out.println("no testing yet.");
System.out.println(calc.atMediumHealthRisk(15,55));
}
public void testOutputAllPatientInfo(HealthRiskCalculator calc) {
System.out.println("\nTesting outputAllPatientInfo");
// TODO: after implementing outputAllPatientInfo:
// comment out the next line and remove the comments from the following block of code
//System.out.println("no testing yet.\n");
calc.outputAllPatientInfo();
}{
Can someone give me advise how to be more efficient.
Thanks to anyone who helps.
Daisy
-
Most of the code is println statements. Could you paste the rest of the code. That is where the real work is being done I believe. That code is what has to be optimized.
For more help, www.NeedProgrammingHelp.com
-
That actually looks fine. If you want to condense the three methods into one, you could add an enumerated constant to your HealthRiskCalculator class that tells what level of risk it is and then inside your consolidated method have a switch statement that performs different operations depending on the health risk level of the HealthRiskCalculator. This would not be as time efficient as having three separate methods, but it would reduce code make it a little more object oriented.
-
Similar Threads
-
By Gary Nelson in forum .NET
Replies: 277
Last Post: 10-01-2003, 12:00 AM
-
By Chaitanya Marvici in forum ASP.NET
Replies: 6
Last Post: 07-21-2003, 09:15 AM
-
By Rob Teixeira in forum .NET
Replies: 5
Last Post: 11-27-2001, 06:12 PM
-
By Danny Bowman in forum .NET
Replies: 152
Last Post: 09-13-2001, 07:23 AM
-
Replies: 90
Last Post: 04-17-2001, 12:45 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|