COP 3538 Data Structures with OOP

COP 3538 Data Structures with OOP

COP 3538 – Data Structures with OOP

Project 2 –Summer 2013

Due: May28th – midnight

Priority Queues, Stacks, and Queues

Using NetBeans 7.1,2or later version, you are to write a Java program using OOP principles to accommodate the following functionality

Assignment#2

Objectives:

Provide student with additional experiences with file input output.

Provide student with exercises in learning UML

Provide student with exercises in Javadoc and its various formats

Provide student with exercises in building an array of objects to support priority queuing.

Provide student with experience in inserting, deleting, and searching a priority queue of objects.

Functionality:

Step 1: Overview: Build Stack, Queue, and Priority Queues: Given a sequential file, Countries.txt on my web page(same input file as Program 1), you are to build a series ofpriority queues discussed ahead, a single regular queue, and one single input stack. You are specifically required to ultimately build twopriorityqueues one for each Region_Nbrwith entries ultimately ordered on Country Name within that region; that is,within the queue for Region_Nbr 2, for example, countries are to ultimately appear alphabetized and only those from region 2.

Array to Stack and to Queue. Initially, you are to read in strings from the input file and create and array of objects of type Country, as stated. You may call this countryArray, if you wish.Each object is to only contain the countryName and countryCapital attributes. Objects in the countryArray from Regions 1 and 2 are then to be inserted a stack in the order in which they are created from the input; objects from Regions 3 and 4 are to be placed into a regular queue in the order in which they too were created. (So you will need to process the countryArray from the beginning position…)

Step 2: Build Priority Queues from the Stack

Using the stack as input, you are to build the two priority queues using the objects in the stack one at a time. Read an object from the stack and put it (insert it) into its proper queue. (priority queue 1 or priority queue 2) (Note: that the order of the entries in the stack will make no difference in developing the priority queue, because each input from the stack will be placed into its proper position in its priority queue – alphabetically arranged ascending.)

Step 3. Display the Priority Queues: Once the two priority queues have been built (please verify as you go), you are to display each of the queues – by region name - with an appropriateleft justified header and detail lines on your screen, such as

Region 1: Northern_Europe

<skip a line>

Denmark

Estonia

Finland

Latvia

Lithuania

Sweden

.<skip two lines; that is, two blank lines should appear, followed by:

Region 2: Western_Europe

Andorra (or whatever countries are ‘in’ Western Europe – alphabetized)

The displaying of these priority queues is to be based on the array itself that implements the priority queue. Thus, the objects will be displayed in ascending order from the first position in the queue to the last position. You will not use the remove() method.

Step 4 – Build Circular Queues from Regular Queue.

You must now create two more queues – but these will be circular queues. Make each of these queue sizes eight. You will now populate these two queues (not priority queues) using input objects from the regular queue you created earlier.

Using the objects from this queue, populate each of the two circular queues – one circular queue for objects of region 3 and one circular queue for objects of region 4.

Challenge: Circular Queues too Small. You will note that your queues in both cases are too small, and this is by design. As you attempt to populate the queues and discover a circular queue full, you need to remove() an element from the queue (use the front index to remove) in order to allow space to add the new object to the rear. You will have to do this more than once per circular queue. Do this until all objects from the regular queue have been added to the circular queues.

As you encounter the situation where you must remove an object from the circular queue, please display the results in the format:

For Region n, item removed from queue: xxxxxx (attribute countryName only)

<These may appear as you discover them in updating your circular non-priority queues. You may single space.

Step5. – DisplayCircularQueues upon completion of Step 4.

As is Step 3, display the Circular Queues with appropriate headers and line spacing. You are to display the circular queues by the removal method, remove(); Your remove should start at the front of the queue, wherever it is, and proceed until the queue is empty.

Bingo! You are done.

UML

You are to include a UML class diagram. You may use Word or Power Point. You may supply a .pdf file or use SmartDraw. Drag your UML design file into your P2 subfolder within your COP3538 desktop folder. It will be included in the zip file to me. Please note that if you elect to do the bonus, you should have a public class Stack and an appropriate Stack controller (just as you have for the Queue). So, you will likely have five classes. If you have any questions, please ask well in advance of the due date.

Javadoc

All programming is to be accompanied by appropriate Javadoc. Generate your Javadoc files and include these in your submission to me. Please review the email and other help files sent to you that provide guidance on Javadoc.

You are to zip all files in your P2 as expected and transmit them to me via Blackboard using the same naming conventions as in P0 and P1. Your zip file is NOT to include your N-number. Rather, it must be project2.youruserid, as project2broggio NOT project2n00010109.

Grade Sheet for Program 2

Source Code – 30 points – stressed again this time. …………………….

Indentation and alignment

Internal comments; Javadoc comments

Scope terminators

Overall program structure

Program Design – 10 points ……………………………………….

Appropriateness of the objects and their services provided

Organization of the object’s contents. Interface to objects

Attribute and method visibility

Javadoc – 10 points ………………………………………………

Appropriatenessand completeness of comments

ALL methods must have Javadoc comments up front that are meaningful, please.

UML – 20 points – stressed this time. …………………………..

Correctness, associations, completeness. This means that the classes you identify are correct, that associations are indicated, and that the attributes and methods are documented within the classes.

Outputs – 30 points – naturally stressed. ………………………

Accuracy and Format

Skip lines in between displayed numbers for readability.

Include headers / descriptors as you may feel appropriate.

Total Points:

 Program must run correctly to receive a passing grade(60 or better) and to receive at least partial credits above. If the program does not successfully run to end of job and include all major functional requirements, all bets are off.

Start early and do this a little at a time. You know the drill. 