Expert answer:C++ details in file

Solved by verified expert:details in file
exercise__5.docx

Unformatted Attachment Preview

Chapter 6
Problem:
A limited number of tickets for the Hoops championship basketball game go on sale
tomorrow and tickets orders are to be filled in the order in which they received. Write a
program that a box-office cashier can use to enter the names and addresses of the persons
ordering tickets together with the number of tickets requested and store this information
in a list. The program should then produce a sequence of mailing labels (name, address,
and number of tickets) for orders that can be filled.
Giving the List class (list.h & list.cpp), design the TicketOrder.h and TicketOrder.cpp.
The test driver bbtickets.cpp as follow:
//— bbticket.cpp –/*——————————————————————-Hoops basketball-ticket program.
Input (keyboard): number of tickets available,
Input (file):
names, addresses of people ordering tickets,
and number of tickets requested
Output:
mailing labels for ticket orders .
Condition:
none.
Uses:
List class with typedef change to
typedef TicketOrder ElementType;
——————————————————————–*/
#include
#include
#include
using namespace std;
#include “List.h”
int main()
{
// to do…
}
The List.h and list.cpp:
//—– List.h —-#ifndef LINKEDLIST
#define LINKEDLIST
#include
#include “TicketOrder.h”
typedef TicketOrder ElementType;
class List
// with ElementType = TicketOrder
{
private:
class Node
{
public:
//—— Node DATA MEMBERS
ElementType data;
Node * next;
//—— Node OPERATIONS
//– Default constrctor: initializes next member to
Node()
: next(0)
{}
//– Explicit-value constructor: initializes data member to dataValue
//-and next member to 0
Node(ElementType dataValue)
: data(dataValue), next(0)
{}
}; //— end of Node class
typedef Node * NodePointer;
public:
//—— List OPERATIONS
List();
/*——————————————————————-Default constructor: builds an empty List object.
Precondition: None
Postcondition: first is 0 and mySize is 0.
——————————————————————–*/
List(const List & origList);
/*——————————————————————-Copy constructor
Precondition: A copy of this list is needed.
Postcondition: A distincr copy has been constructed.
——————————————————————–*/
~List();
/*——————————————————————-Destructor
Precondition: This list’s lifetime is over.
Postcondition: This list has been destroyed.
——————————————————————–*/
const List & operator=(const List & rightSide);
/*——————————————————————-Assignment operator
Precondition: This list must be assigned a value.
Postcondition: A copy of rightSide has been assigned to this list.
——————————————————————–*/
bool List::empty();
/*——————————————————————-Check if this list is empty
Precondition: None.
Postcondition: true is returned if this list is empty, false if not.
——————————————————————–*/
void insert(ElementType dataVal, int index);
/*——————————————————————-Insert a value into a list at a given index.
Precondition: index is a valid list index: 0 <= index <= mySize, Postcondition: dataVal has been inserted into the list at position index, provided index is valid.. --------------------------------------------------------------------*/ void erase(int index); /*-------------------------------------------------------------------Remove a value from a list at a given index. Precondition: index is a valid list index: 0 <= index < mySize Postcondition: dataVal at list position index has been removed, provided index is valid. --------------------------------------------------------------------*/ int search(ElementType dataVal); /*-------------------------------------------------------------------Search for an data value in this list. Precondition: None Postcondition: Index of node containing dataVal is returned if such a node is found, -1r if not. --------------------------------------------------------------------*/ void display(ostream & out) const; /*-------------------------------------------------------------------Display the contensts of this list. Precondition: ostream out is open Postcondition: Elements of this list have been output to out. --------------------------------------------------------------------*/ int nodeCount(); /*-------------------------------------------------------------------Count the elements of this list. Precondition: None Postcondition: Number of elements in this list is returned. --------------------------------------------------------------------*/ private: //------ DATA MEMBERS NodePointer first; int mySize; }; //--- end of List class ostream & operator<<(ostream & out, const List & aList); istream & operator>>(istream & in, List & aList);
#endif
//—– List.cpp —-#include
using namespace std;
#include “List.h”
//– Definition of the class constructor
List::List()
: first(0), mySize(0)
{}
//– Definition of the copy constructor
List::List(const List & origList)
{
mySize = origList.mySize;
first = 0;
if (mySize == 0) return;
List::NodePointer origPtr, lastPtr;
first = new Node(origList.first->data); // copy first node
lastPtr = first;
origPtr = origList.first->next;
while (origPtr != 0)
{
lastPtr->next = new Node(origPtr->data);
origPtr = origPtr->next;
lastPtr = lastPtr->next;
}
}
//– Definition of the destructor
inline List::~List()
{
List::NodePointer prev = first,
ptr;
while (prev != 0)
{
ptr = prev->next;
delete prev;
prev = ptr;
}
}
// Definition of empty()
bool List::empty()
{
return mySize == 0;
}
//– Definition of the assignment operator
const List & List::operator=(const List & rightSide)
{
mySize = rightSide.mySize;
first = 0;
if (mySize == 0) return *this;
if (this != &rightSide)
{
this->~List();
List::NodePointer origPtr, lastPtr;
first = new Node(rightSide.first->data); // copy first node
lastPtr = first;
origPtr = rightSide.first->next;
while (origPtr != 0)
{
lastPtr->next = new Node(origPtr->data);
origPtr = origPtr->next;
lastPtr = lastPtr->next;
}
}
return *this;
}
//– Definition of insert()
void List::insert(ElementType dataVal, int index)
{
if (index < 0 || index > mySize)
{
cerr << "Illegal location to insert -- " << index << endl; return; } mySize++; List::NodePointer newPtr = new Node(dataVal), predPtr = first; if (index == 0) { newPtr->next = first;
first = newPtr;
}
else
{
for(int i = 1; i < index; i++) predPtr = predPtr->next;
newPtr->next = predPtr->next;
predPtr->next = newPtr;
}
}
//– Definition of erase()
void List::erase(int index)
{
if (index < 0 || index >= mySize)
{
cerr << "Illegal location to delete -- " << index << endl; return; } mySize--; List::NodePointer ptr, predPtr = first; if (index == 0) { ptr = first; first = ptr->next;
delete ptr;
}
else
{
for(int i = 1; i < index; i++) predPtr = predPtr->next;
ptr = predPtr->next;
predPtr->next = ptr->next;
delete ptr;
}
}
//– Definition of search()
int List::search(ElementType dataVal)
{
int loc;
List::NodePointer tempP = first;
for (loc = 0; loc < mySize; loc++) if (tempP->data == dataVal)
return loc;
else
tempP = tempP->next;
return -1;
}
//– Definition of display()
void List::display(ostream & out) const
{
List::NodePointer ptr = first;
while (ptr != 0)
{
out << ptr->data << " "; ptr = ptr->next;
}
}
//– Definition of the output operator
ostream & operator<<(ostream & out, const List & aList) { aList.display(out); return out; } //-- Definition of nodeCount() int List::nodeCount() { int count = 0; List::NodePointer ptr = first; while (ptr != 0) { count++; ptr = ptr->next;
}
return count;
}

Purchase answer to see full
attachment

How it works

  1. Paste your instructions in the instructions box. You can also attach an instructions file
  2. Select the writer category, deadline, education level and review the instructions 
  3. Make a payment for the order to be assignment to a writer
  4.  Download the paper after the writer uploads it 

Will the writer plagiarize my essay?

You will get a plagiarism-free paper and you can get an originality report upon request.

Is this service safe?

All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 20% with the discount code ESSAYHELP