Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Goals of this Assignment In this assignment you will: Modify and use a tightly-coupled pair of C++ classes. Use a command-line argument for main(); To

Goals of this Assignment In this assignment you will:

Modify and use a tightly-coupled pair of C++ classes.

Use a command-line argument for main();

To implement and use a circular linked list.

The Silly Story Professor I.M.A.Meany is a stickler for being on time; he is intolerant of late work and decided to train his students to get their programs done on time. He allows one day of grace, then writes the names of all late students into a file named "late.txt". Pretend that you are his teaching assistant. He has asked you to take the names from the file, make a circular linked list of names, and perform an eeny-meeny-miney-mo process to select the loser. That person gets a zero on the assignment. Everyone else gets whatever grade they earn, minus a late penalty.

Classes Needed

Define a class named Student. Each student will be represented by a boolean fiag, seen, and two

strings, fname and lname. The Student constructor must have two string parameters, for the

names. It should copy the names into the Student object and set seen to false.

Define a class named CList (circular list) and a helper class named Cell (Which stores Student in

the Data part). The last Cell on a CList points back to the first Cell, so that a program can "walk" round and round the list in a circle. See Section 4 for details and guidance.

Choosing the Loser: Due February 24th, 2022 Setup.

Call banner(). Then open the late file properly and fill the list with Cells, each containing one names from the file.

Instantiate your CList class, which should be initially empty.

Open the file and attempt to read the first line (two names, separated by a space).

If there are zero names in the file, end the program immediately with a congratulatory

comment.

Otherwise, read the file, one student at a time, install the student in a new Cell, and attach the

new Cell to the tail end of the list. Count the cells you create.

When eof is reached, close the file and make the last Cell on the list point back to the first one,

forming a circle.

If there is exactly one name in the file, end the program immediately with a comment announcing the loser. You don't even need to add anything to the CList.

Otherwise, set a pointer (current) to the first student on the list.

Use a string library function to get N, the length of the current last name.

Walk around the circular list for N steps and look at the seen flag for that student. The first

student who was previously seen is the loser. Announce his/her name and end the process.

Otherwise, mark the current student as seen.

Repeat this process from step 3.

Properly free all dynamic memory. Call bye().

Circular Linked Lists

The Cell class can be defined one of two ways, below. For this program try to implement the

way you did not implement in previous program. Adapt the code from queue.hpp.

Cell is a fully separate class that gives friendship to List. All members of Cell are private.

Cell is a class inside the private area of List. All members of Cell are public. In your List class, define members for the head of the list and for walking around it. You don't need a count field for this application. Initially, the List should be empty, that is, the head of the list should be initialized to nullptr. The list described here is a straight-line list until eof is reached, and the ends are joined. All cells are inserted at the tail of the list because that is easiest.

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_2

Step: 3

blur-text-image_3

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

Write a paper on "Personal Leadership Action Plan"

Answered: 1 week ago