查看: 995|回复: 5
|
[急]Assignment 不会做!!!
[复制链接]
|
|
我现在有个Assignment明天要交,可是我不会做。我知道其实不难,可是我的JAVA不好。如果有那位大大有空帮帮忙,请留下英雄的MSN或其他的联络方式。请求上帝让位英雄救救我吧!
Assignment资料:
这个Assignment是运用另一个JAVA程式MARK的。他已经提供了很多资料了,只需要以填补方式完成罢了!有两个Class。
[ 本帖最后由 郑汉宾 于 6-4-2006 12:15 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 6-4-2006 02:33 PM
|
显示全部楼层
原帖由 郑汉宾 于 6-4-2006 12:10 PM 发表
我现在有个Assignment明天要交,可是我不会做。我知道其实不难,可是我的JAVA不好。如果有那位大大有空帮帮忙,请留下英雄的MSN或其他的联络方式。请求上帝让位英雄救救我吧!
Assignment资料:
这个Assignme ...
居然已经给你很多的资料了,你就尝试做做看。。这里的条规是不可以在没有自己尝试以前就问答案的 |
|
|
|
|
|
|
|
楼主 |
发表于 6-4-2006 02:37 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 6-4-2006 03:20 PM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 6-4-2006 05:25 PM
|
显示全部楼层
import java.util.*;
public class Task implements Comparable{
/**
* An exception class thrown when an error is detected in the data or
* method calls for the Task class.
*/
public class TaskException extends RuntimeException{
public TaskException(String s){
super(s);
}
};
/**
* The string name for the class. The name will be used to uniquely identify
* classes in the precedence network.
*/
private String id;
/**
* The duration of the task. Must be greater than or equal to zero.
*/
private int duration;
/**
* The earliest start time for the task
*/
private int earliestStart;
/**
* The earliest finish time for the task. This value
* should be (earliestStart + duration).
*/
private int earliestFinish;
/**
* The latest start time for the task. This value must
* be greater than or equal to the earliestStart time, and
* equal to the (latestFinish - duration).
*/
private int latestStart;
/**
* The latest finish time for the task. This value must be greater
* than or equal to the earliestFinish time, and must equal the
* (latestFinish + duration).
*/
private int latestFinish;
/**
* The float associated with the task. Greater than or equal to zero.
* Should be equal to both (latestStart - earliestStart) and
* (latestFinish - earliestFinish).
*/
private int taskFloat;
/**
* The set of predecessor tasks for this task.
* Can be empty.
*/
private Set from;
/**
* The set of successor nodes for this task.
* Can be empty.
*/
private Set to;
/**
* This method is required for the Task class to implement the
* Comparable interface.
* <p>Compares this Task with another object (that must also be a Task)
* by comparing the id values for each task.
* <p>Will throw an exception if
*/
public int compareTo(Object t){
return Integer.MAX_VALUE;
}
/**
* A Task constructor.
*
* <p>This constructor is given the task name and duration, and
* initialises the earliest start, latest start and float to zero,
* and the earliest and latest finish to the duration. The sets
* of predecessor and successor tasks are initialised to empty sets.
* <p>It is assumed that task names are unique, although this class
* can not test for this.
* @param id the task name
* @param duration the duration of the task.
*/
public Task(String id, int duration){
}
/**
* @return The name of the task.
*/
public String name(){ return null;}
/**
* @return The duration of the task
*/
public int duration(){return Integer.MAX_VALUE; }
/**
* @return The earliest start time for the task.
*/
public int earliestStart(){return Integer.MAX_VALUE;}
/**
* @return The earliest finish time for the task.
*/
public int earliestFinish(){ return Integer.MAX_VALUE;}
/**
* @return The latest start time for the task
*/
public int latestStart(){ return Integer.MAX_VALUE;}
/**
* @return The latest finish time for the task.
*/
public int latestFinish(){return Integer.MAX_VALUE;}
/**
* @return The float time for the task.
*/
public int taskFloat(){ return Integer.MAX_VALUE;}
/**
* Change the name of the task
* @param newName The new task name.
*/
public void rename(String newName){}
/**
* Set the duration of the task.
* <p>This method sets the duration for a task and also updates
* the earliest finish time (earliest start time +duration),
* ensures the latest finish time is at least equal to the earliest finish
* time, that the latest start time is (latest finish time - duration),
* and that the task float is (latest start time - earliest start time).
*
* <p>This task does not check fhe relationships between the earliest finish
* time of this task and the earliest start times of successor tasks, or
* the latest start time of this task and the earliest finish times of
* predecessor tasks.
*
* <p>This method throws a TaskException if the new duration is negative.
*
* @param d The duration of the task.
*/
public void setDuration(int d){
}
/**
* Sets the earliest start time for the task.
* <p>This method sets the earliest start time, and then updates the
* earliest finish time (Earliest start + duration). If the latest finish
* time is less than the earliest finish time, the latest finish time is
* set to the earliest finish (and the the latest start and task float
* are updated).
* <p>This task does not check the time relationships implied by the set
* of predecessor and successor tasks.
*
* <p>The method throws a TaskException if the new earliest start time
* is negative.
*
* @param es The earliest start time for the task.
*/
public void setEarliestStart(int es){
}
/**
* Sets the latsst finish time for the task.
* <p>This method sets the latest finish time time,and then updates the
* latest start time and task duration.
* <p>A TaskException is thrown if the new latest finish time is less
* than the earliest finish time.
*
* <p>This task does not check the time relationships implied by the set
* of predecessor and successor tasks.
*
* @param lf The latest finish time for the task.
*/
public void setLatestFinish(int lf){
}
/**
* Adds a task to the set of successor tasks for this task.
*
* @param s The task to add to the successor set.
*/
public void addSuccessor(Task s){
}
/**
* Adds a task to the set of predecessor tasks for this task.
* @param p The task to add to the predecessor set.
*/
public void addPredecessor(Task p){
}
/**
* @return An iterator for the successor tasks of this task.
*/
public Iterator successor(){
return null;
}
/**
* @return An iterator for the predecessor tasks of this task
*/
public Iterator predecessor(){
return null;
}
/**
* @return The number of successor tasks
*/
public int successorCount(){
return Integer.MAX_VALUE;
}
/**
* @return The number of predecessor tasks
*/
public int predecessorCount(){
return Integer.MAX_VALUE;
}
/**
* Do not change the code for this method - the testing will depend on
* the format of the output from this method
* @return A string representation of a Task object.
*/
public String toString(){
String s = "(TASK: id=" + id + ", D=" + duration + ", ES=" + earliestStart
+ ", EF=" + earliestFinish + ", LS=" + latestStart
+ ", LF=" + latestFinish + ", F=" + taskFloat +" ,to=";
Iterator i = to.iterator(); s = s+"[";
while (i.hasNext()) s = s +((Task) i.next()).name() + " ";
s = s+"], from=[";
i = from.iterator();
while( i.hasNext()) s = s + ((Task)i.next()).name() + " ";
s = s + "])\n";
return s;
}
} |
|
|
|
|
|
|
|
楼主 |
发表于 6-4-2006 05:26 PM
|
显示全部楼层
import java.util.*;
public class Network{
/**
* A exception class for errors in the usage of this class.
*/
public class NetworkException extends RuntimeException{
public NetworkException(String msg){ super(msg);}
}
/**
* tasks is a mapping from tasks names to the tasks
* in the precedence network.
*/
private Map tasks;
/**
* Default constructor.
* <p>Creates a network without any tasks.
* <p>You <b>must</b> use a TreeMap for tasks, as the marking will depend
* on the order that tasks within the map are printed.
*/
public Network(){
}
/**
* Adds a task to the task set of the network.
* @param t The task to add to the network.
*/
public void addTask(Task t){
}
/**
* Adds a task to the task set of the network.
*
* @param id The task name
* @param duration The duration of the task.
*/
public void addTask(String id, int duration){
}
/**
* Adds a dependency to the network, that task <i>from</i> must be
* completed before tasks <i>to</i> can start.
*
* <p>The tasks are identified by their names, which are assumed to be
* unique.
*
* @param from A predecessor task for tasks <i>to</i>.
* @param to A successor task for tasks <i>from</i>.
*/
public void addDependency(String from, String to){
}
/**
* Find the starting task in the precedence network.
* <p>It is assumed there is a unique starting task (a task without
* predecessors).
* <p> A NetworkException is thrown with the string
* message <i>"Invalid network: No first task"</i> if there is not a
* task without predecessors.
* <p>A NetworkException is thrown with the string
* message <i>"Invalid network: More than one first task"</i> if there is
* more than one task without predecessors.
* <p>Design note: Possible future change<br>
* It would likely be better to have returned the name of the first
* task, and to provide methods within this class to access the data
* associated with a task given the name of the task. This would allow
* also allow the Task class to be made into an inner class to completely
* hide the representation of the precedence network. However, this would
* make marking harder!
*
* @return The first task in the precedence network.
*/
public Task findFirst() throws NetworkException{
return null;
}
/**
* Find the last task in the precedence network.
* <p>It is assumed there is a unique finishing task (a task without
* successors).
* <p>A NetworkException is thrown with the string
* message <i>"Invalid network: No last task"</i> if this is not a task
* any successor tasks.
* <p>A NetworkException is thrown wiht the string
* message <i>"Invalid network: More than one last task"</i> if there is
* more than one task without any successor tasks.
* @return The last task in the precedence network.
*/
public Task findLast() throws NetworkException{
return null;
}
/**
* Do the forward pass in the algorithm to determine the critical tasks.
*
* <p>This method should update the earliest finish time for the node
* passed to it, and then iterate over all the successor tasks. For
* each successor task, if the earliest start time of the successor task
* is less than the earlier finish time for this task, the earliest start
* time of the successor task is updated and then forwardPass is called for
* the successor node.
* <p>This allows the whole network to be recursively updated by passing
* the first node to the initail call of forwardPass().
* @param currentTask A node (a task) in the network
*/
public void forwardPass(Task currentTask){
}
/**
* Do the backward pass in the algorithm to determine the critical tasks.
* <p>This method should update the latest finish time to be the minimum of
* the latest start time of this tasks successor tasks, and then, for each
* predecessor task, call backwardPass().
* <p>The last task should be passed to this method in the initial call.
* @param currentTask The current task for backward pass processing.
*
*/
public void backwardPass(Task currentTask){
}
/**
* Return the set of critical tasks assuming a forward and backward pass
* has already been made across the network.
* <p>The critical tasks are the tasks with float of zero.
*
* @return The set of tasks with float equal to zero.
*/
public Set criticalTasks(){
return null;
}
/**
* An method to do the forward and backward passes and then return
* the set of critical tasks.
*
* @return The set of critical tasks (with float equal to zero)
*/
public Set findCriticalTasks(){
forwardPass(findFirst());
backwardPass(findLast());
return criticalTasks();
}
/**
* A method to conver the network to a string.
* <p>You should not change this method as the testing of your code
* will assume the network is printed using this method.
*
* @return a string representation of the network.
*/
public String toString(){
return tasks.toString();
}
} |
|
|
|
|
|
|
| |
本周最热论坛帖子
|