The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

lists of lists and recursion

Posted by SC on June 23, 2001 at 11:13 AM

hi all
i have a problem in recursion. I was given the following info:

class abstract Plan
{
....
public String name()
public abstract int howLong()//time needed to finish
// the plan
}

/** the simplePlan is a single task, which has a name indicating what must be done, and a duration indicating how long it will take. We can build larger plans from existing ones in two ways: swequentially or concurrently.
*/
class SimpleTask extends Plan
{
int _duration;
......
int howLong()
{
return _duration; //This line is my answer
}
}

/** the sub-plans must be done one after the other
so the total time taken is the sum */
class SequentialPlan extends Plan
{
LinkedList _pieces; //holds Plan objects

int howLong()
{
// define
}


/** the sub-plans all start together,
so the total time taken is the maximum time*/
class SequentialPlan extends Plan
{
LinkedList _pieces;

int howLong()
{
// define
}
}

for example, sub-plan "class" has one task: "design 4" (means 4 days), after we finish the design, we need to do the coding: which has two concurrent sub-plans: account and main.
Under account, we need to do the following step by step: interface 1, code 5, test 2.
Under main, we need to do the following step by step:
interface 1, code 4, test 1.
so for this sub-plan "class", the time needed is: 12, which consists of 4 days from design and the longer of coding from account, 8.
We are required to define the howLong() method. for each of the three child classes.

can anyone give me a hint to start???
I've tried lots of ways, but seems something is missing all the time. Really appreciate any help.

Best regards,
SC





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us