Project #40637 - Linked Lists

QUESTION 1 QUESTION 1 QUESTION 1 QUESTION 1 QUESTION 1

Part 1 

Design and implement a class Menu which uses doubly linked lists as main data structures.
 A menu consists of main menu items, organized as a doubly linked list, each main menu item having associated a submenu, organized as a doubly linked list of submenu items (see an example of a Menu object in the file MenuExample.pdfposted below).

The class Menu should define a default constructor which builds an empty menu and the following methods:

addMainMenuItem, for adding a new main menu item with empty submenu. The method should have the following signature:

     
public boolean addMainMenuItem(String newItem, String existingItem, 
                                                           int position)


This method works in the following way:
(i) if parameter existingItem is null, the newItem will be added at the end of the list;
(ii) if the parameter existingItem is not null, the newItem will be added before existingItem if parameter position is -1 and after the existinItem if parameter position is 1;

deleteMainMenuItem, deletes the main menu item specified by name;

addSubMenuItem, adds a submenu item specified by name to a main menu item specified by name;

toString, traverses the linked lists data structures and generates the string representation of a menu object, organized on lines. Each line should include the main menu item followed by its submenu items. The items should be separated by a semicolon character. The toString method will be invoked from other programs (such as the driver of Part 2) to display the menu.

Note. If necessary, additionally (housekeeping) methods may be defined for the class Menu. Give reasons for the new added methods. The class Menu.java should compile without errors.

Part 2

Write a driver program MenuTest.java to test the Menu class.  In the driver program, do the following tasks: 

a) Read menu items from the input file Menu.txt and build a menu object which includes the specified items. Each file line contains a main menu item followed by its submenu items, all items being separated by the semicolon character. After reading the file and building the menu, display the menu. 

Example of the content of the input file Menu.txt:

File;New;Open;Save;SaveAs;Close;
View;Color;Gray;Zoom;Ruler;Grid;
Process;Select;Move;Rotate;Scale;Delete;Group;
About;Release;Version;Contact;Description; 

In the example above, File, View, Process and About are the main menu items. The main menu item File has New, Open, Save, SaveAs and Close as its submenu items.

b) Add a new main menu item and its associated submenu before a main menu item specified by the user. Read the data from the input file MenuAdd.txt. Using thetoString method, display the menu after adding the new item.

c) Delete the previously added menu item. Using the toString method, display the menu after deleting the menu item.

d) Add a new main menu item and its associated submenu after a main menu item of an existing menu. Read the data from the input file MenuAdd.txt. Using thetoString method, display the menu after adding the new item.

The input file MenuAdd.txt contains one line specifying the new main menu item and its submenu items.

Example of the content of the input file MenuAdd.txt for adding a new menu item

Layout;Margins;Orientation;Size;

The example above indicates that the main menu item Layout has the submenu items Margins, Orientation and Size.

Note.
 The input files Menu.txt and MenuAdd.txt will be created by the students using a simple text editor (such as Notepad).

Submission requirements (updated Sept 17)

Submit the following before the due date listed in the Calendar:

1.Menu.java, MenuTest.java, Menu.txt and MenuAdd.txt files.
2. A document file containing: (2.1) a short question(s) analysis, (2.2) design decisions and assumptions, (2.3) test cases and two relevant screenshots, (2.4) error handling, (2.5) lessons learned and (2.6) possible improvements. The size of the document file (including the screenshots) should be of two pages, single spaced, font size 12.

 

Subject Computer
Due By (Pacific Time) 09/21/2014 12:00 am
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy