Vous êtes sur la page 1sur 2

CS/CE 2336 Computer Science II (Advanced Java Programming), Summer 2012

Assignment 3
Due at 11:59pm, Friday 29th- 100pts
Directions: Implement a class or classes which contain the following:
Part 1: Implement a recursive algorithm which solves the Towers of Hanoi problem. This program
should take as input from the user the number of disks to be sorted. It should output the steps of the
algorithm displayed in a manner similar to the following:
Start:7disksareonpoleA
Step1:disk1ismovedfrompoleAtopoleC
Step2:
Finish:7disksareonpoleB
Part 2: Implement a graph in the following manner: graph G is a digraph defined by G = (V, E),
where V is the set of vertices in the graph, and E is the ordered set of edges defining G. The sets V
and E are contained in a file called graph_input.dat. This file contains text only. You are to read in
the contents of this file, and using Generics create an ArrayList containing all the elements of the set
V cast as GeometricObjects. The set E should also be stored in an ArrayList using Generics, in
whatever format you choose. You will parse/filter the Arraylist for V, cast every fourth element
(beginning with element 0 (the first one)) as a circle (using Generics), and then store them in another
ArrayList defined by a Generic type of Circle. Finally, using V and E, you will output to a file
called graph_output.txt the adjacency list, adjacency matrix, and incident matrix for G in text
format.
Requirements: Programming assignments should be submitted using your eLearning account. Each
programming assignment must contain the following:
1. A text copy of all source code including its documentation (.java)
2. A file showing test cases for your programs input and displayed output (.doc)
3. Copies of all Java executable code (.class) files needed to execute the program.
4. All files (.java, .class, .jar, .doc, etc.) should be submitted in a single .zip file.

Program documentation standards (example):


/
****************************************************************************************
Program: program name
* Function: program function (descriptive, not literal)
* Input: program input (descriptive, not literal)
* Output: program output (descriptive, not literal)
1

* Notes: any additional information about this program, particularly if it uses code written by other authors,
* in which case it should be properly referenced (i.e., other author name, website, etc.)
***************************************************************************************/
import
//global variables
int x; //describes global variable x
int y; //describes global variable y

//this class does something really important


public class makeItCool ( )
{
double z;
//describes local variable z

stuff; //this stuff does some really cool stuff

//if this stuff isnt cool, then make it cool


if (! cool)
{
cool = true;
//now everythings cool
}
else
{
return 0;

//already cool

}
}
public class( )

Vous aimerez peut-être aussi