Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the last assigment for my CSIS C++ class and have not done much with this type of programming, I thought this would be

This is the last assigment for my CSIS C++ class and have not done much with this type of programming, I thought this would be something that someone can help me on, I will try this on my own and post updates as I go but until then I would like either instructions on this or to see it be done.

THIS ASSIGNMENT MAY BE WORKED ON AS A GROUP.

For those of you who aren't planning on doing any programming after you graduate, this is probably too hard for you. If you get credit for the other assignments, you can certainly pass the course without doing this. 
If you think you'd like to program professionally, this assignment is a good aptitude test for you. 
ll1 Option A: 50 points. No disk I/O. ll2 Option B: 60 points: linked list with binary disk storage using fread() and fwrite(), no C++ streams. 
Scores are independant and additive. (110 points availabe total). Must be claimed in order, ll2 won't count for ll1 if that's all you do. File dates will be checked. 
This assignment may only be submitted by students with credit for preceeding assignments 1,2,4,5 

Assignment: Create an in-memory Circularly Linked List without using any Standard Library constructs like linkedlist objects. In other words, you must create and link structs or class objects manually without using any kind of container class. 

A circularly linked list is a list anchored by a variable which points to the first node, and all other nodes are accessed by walking forward or backward in the list using the pointers in the node structure. 
Do not use pre-provided C++ list container objects like list. 
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= BASIC ASSIGNMENT: 
Create an in-memory CIRCULAR DOUBLY LINKED linked-list database program which displays a menu screen similar to the following... 
 LINKED LIST PROGRAM e) Add new agent to end of list l) List all agents n) Display Next record p) Display Previous record q) Quit program ============================================================= Current Record: 
 0X567A:::0X620A:::0X640D James Bond 001 
...and which processes SINGLE KEYSTROKE INPUT from the user. On the Linux system, this is possible using the instructor's 
 /var2/local/include/getchne.h 
code, on Microsoft, use the getch() function which should be in the System.Console namespace now, or listed in conio.h. 
 struct prs { int useme ; char name[30] ; int num ; struct pby * prev ; struct pby * next ; } *P, *phere , *pnew ; 
Access to the list will be via a prs * "anchor" ; variable which will serve as the access point to the list by pointing to the first record. Thereafter, each record will be accessed via the preceeding record. Each record should point "forward" to the next record and "back" to the preceeding record.
SUGGESTIONS FOR FUNCTIONS: print_rec(): display a record, including pointer contents. pop_menu() : clear screen, display menu, get choice, and return number of choice to calling routine. In addition to displaying the menu choices, it should display the "current" record in the list, that is, the one phere points to. 
listall(): calls print_rec to display all records in list. alloc_rec() : creates a record edit_rec() : prompts the user for input and fills the record fields. Design so that later on you can include extra functions. Work for simplicity and clarity. MAJOR HINTS: To do "display next record" or "display previous record" all you have to do is: "phere = phere->next" or "phere = phere->prev" and then re-display the program screen. If you think about it, you ought to be able to use the same logic in the "list all agents" option. Situation: three records linked into list (1, 2, and 3). 0003 total records e) Enter a new agent l) List agents in file n) Next Struct in List p) Prev Struct in List q) Quit program 0x9a48040 0x9a48078 0x9a48008 three 3 0x9a48078 0x9a48008 0x9a48040 one 1 0x9a48008 0x9a48040 0x9a48078 two 2 0x9a48040 0x9a48078 0x9a48008 three 3
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 
DISK STORAGE OPTION: Create a program which does the following: 0. Manipulates Records as Class pby Objects. (Class pby fields defined below:) 1. Loads Linked List from diskfile, if it exists. EITHER: in one single block I/O operation, into an area of ram allocated precisely to hold it as an array of structs. Once in RAM, step through the array of structs, connecting the pointers in each record to the records ahead and behind them, to produce a doubly-linked circular list (serial linkage, both "next" and "prev" pointers correctly set) OR: read file one record at a time, allocate each new record discretely, and link it into the list. After file is read, close it, and display menu for users. If no file found, advises user and creates new database from user input. New structs may then be added one at a time, with user input from the keyboard. When the program ends, save all structs, one at a time, to a binary disk file. The design of the struct is up to you, and you may re-use as much of Assignment 6 as you like, to speed up the task. LINKED LIST PROGRAM e) Enter a new agent to end of list n) Next record p) Previous record l) List agents in database d) Delete agent file q) Quit program ======================================== Current Record: James Bond 001 Previous: 0X567A Current: 0X620A Next: 0X640D 2. Allows the user to A.) Display the whole list to the screen, B.) Add a record to the end of the list by keyboard input of fields contents. C.) Display the next or previous struct in list. D.) Quit program saving the list to disk. 3. Uses binary (unformatted fread or system-level) i/o. PROGRAMMING SUGGESTIONS/HINTS: Modularize the program so that reading in and reorganizing pointers in the list, displaying a struct, writing a single struct to disk, writing the array out, getting struct data from the keyboard, are in separate procedures, all driven by a main function built around a user menu. If you write this program well, it will serve you as the basic example for many useful programs you will want to develop for yourself in years to come. Work for simplicity and clarity. Extra Credit: Design program to include delete functions, search functions, and edit functions. Extra Extra: use dynalloced arrays of struct pointers to provide SORTED "listall" access to list on NAME and NUMBER fields by using a sorted array of pointers. (Download and run lldex binary for example.) Either alternative uses exactly the same record specs. Sample data files are provided, which have records in the form: Full-on extra point mode accessing nodes via sorted pointer arrays: (Array elements point to records, and each is sorted on a different field. The nodes don't change positions in the list, that would be slow. This is what is meant by "indexing" databases. In fact, this is the same kind of code Ashton Tate used on the first dBase product, and made millions.) LINKED LIST PROGRAM d (elete current record e (nter new agent l (ist all agents m (odify current record n (ext agent p (revious agent q (uit program s (ort by name # (ort by number t (hrow away file DESIGN CONSIDERATION: There are TWO basic states of nature for the list as a whole: 1.P has no address in it, which indicates that the user is creating the FIRST node, and 2.P has an address in it, indicating that a list already exists. Obviously, it's crucial to initialize all your pointers when the program starts. This kind of assignment really tells how much you know. ALL THAT A PROGRAM "KNOWS" IS CONTAINED IN VARIABLES. Use struct pby * P as the "anchor". Use struct pby * phere as the "current record". Use struct pby * pnew as the "new record". 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

4. Who should be invited to attend?

Answered: 1 week ago