Question

A. Please explain function below: unorderedArrayListType::unorderedArrayListType(int size) : arrayListType(size) { } B. Please explain function below:...

A. Please explain function below:

unorderedArrayListType::unorderedArrayListType(int size)
: arrayListType(size)
{
}

B. Please explain function below:

voidunorderedArrayListType::remove(intremoveItem)
{
int loc;

if (length == 0)
cout << "Cannot delete from an empty list." << endl;
else
{
loc = seqSearch(removeItem);

if (loc != -1)
removeAt(loc);
else
cout << "The item to be deleted is not in the list."
<< endl;
}
}

C. Please explain function below:

What is the output of the following code?

int x = 0;

int y = 1;

void print() {

cout << "small: -- " << endl

<< "x: " << x << ", ", y = " << y << endl;

}

D. Please explain function below:

Please explain function below:

voidbookType::setBookInfo(string title, string ISBN,
string Publisher, intPublishYear,
stringauth[], double cost, int copies,
intauthorCount)
{
inti;

bookTitle = title;
bookISBN = ISBN;
bookPublisher = Publisher;

bookPublishYear = PublishYear;

noOfAuthors = authorCount;

for (i = 0; i < noOfAuthors; i++)
authors[i] = auth[i];

price = cost;
quantity = copies;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A. Please explain function below:

unorderedArrayListType::unorderedArrayListType(int size)
: arrayListType(size)
{
}

Explanation: Its a parameterised constructor with class name unorderedArrayListType that takes input as size and initialised arrayList with length equal to the size passed.


-----------------------------------------------------------------------------------------------------------------------------------------------------

B. Please explain function below:

void unorderedArrayListType::remove(intremoveItem)
{
int loc;

if (length == 0)
cout << "Cannot delete from an empty list." << endl;
else
{
loc = seqSearch(removeItem);

if (loc != -1)
removeAt(loc);
else
cout << "The item to be deleted is not in the list."
<< endl;
}
}

Explanation: This function removes an item from unorderedArrayList, the function proceeds in following way. If first checks if the arrayList has atleast one element . If the size is 0 then just return because there is no element to delete.
Otherwise find the position of the element to be deleted using sequential search. Then just call the function remove At location by passing the location of the element.


------------------------------------------------------------------------------------------------------------------------------------------------------------

C. Please explain function below:

What is the output of the following code?

int x = 0;

int y = 1;

void print() {

cout << "small: -- " << endl

<< "x: " << x << ", ", y = " << y << endl;

}

Output: small: -- x: 0, y = 1

--------------------------------------------------------------------------------------------------------------------------

D. Please explain function below:

Please explain function below:

voidbookType::setBookInfo(string title, string ISBN,
string Publisher, intPublishYear,
stringauth[], double cost, int copies,
intauthorCount)
{
inti;

bookTitle = title;
bookISBN = ISBN;
bookPublisher = Publisher;

bookPublishYear = PublishYear;

noOfAuthors = authorCount;

for (i = 0; i < noOfAuthors; i++)
authors[i] = auth[i];

price = cost;
quantity = copies;
}

Explanation:  setBookInfo is the mutator that sets the book information with the argument passed to the function.
It sets the book title, publisher, year, price, quantity and the author list.

Thanks, PLEASE COMMENT if there is any concern. Let me know if you need more information

Add a comment
Know the answer?
Add Answer to:
A. Please explain function below: unorderedArrayListType::unorderedArrayListType(int size) : arrayListType(size) { } B. Please explain function below:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A. Please explain function studentType(): studentType::studentType() { numberOfCourses = 0; sId = 0; isTuitionPaid = false;...

    A. Please explain function studentType(): studentType::studentType() { numberOfCourses = 0; sId = 0; isTuitionPaid = false; for (inti = 0; i < 6; i++) coursesGrade[i] = '*'; } B. Please explain function arrayListType() and :~arrayListType() arrayListType::arrayListType(int size) { if (size <= 0) { cout << "The array size must be positive. Creating " << "an array of the size 100." << endl; maxSize = 100; } else maxSize = size; length = 0; list = new int[maxSize]; } arrayListType::~arrayListType() {...

  • This project is divided into 3 parts: Part 1. Create a new project and download the arrayList and...

    This project is divided into 3 parts: Part 1. Create a new project and download the arrayList and unorderedArrayList templates that are attached. Create a header file for your unorderedSet template and add it to the project. An implementation file will not be needed since the the new class will be a template. Override the definitions of insertAt, insertEnd, and replaceAt in the unorderedSet template definition. Implement the template member functions so that all they do is verify that the...

  • The function retrieveAt of the class arrayListType is written as a void function. Rewrite this function...

    The function retrieveAt of the class arrayListType is written as a void function. Rewrite this function so that it is written as a value returning function, returning the required item. If the location of the item to be returned is out of range, use the assert function to terminate the program. note: please give all code in c++ below is the class and implementation(a test program would be helpful in determining how to use it): class arrayListType { public:    ...

  • fully comments for my program, thank you will thumb up #include <iostream> #include <fstream> #include <string>...

    fully comments for my program, thank you will thumb up #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; struct book { int ISBN; string Author; string Title; string publisher; int Quantity; double price; }; void choice1(book books[], int& size, int MAX_SIZE) { ifstream inFile; inFile.open("inventory.txt"); if (inFile.fail()) cout <<"file could not open"<<endl; string str;    while(inFile && size < MAX_SIZE) { getline(inFile, str); books[size].ISBN = atoi(str.c_str()); getline(inFile, books[size].Title);    getline(inFile, books[size].Author); getline(inFile, books[size].publisher);          getline(inFile,...

  • #include <iostream> #include <fstream> using namespace std; //constants const int CAP = 100; //function prototypes bool...

    #include <iostream> #include <fstream> using namespace std; //constants const int CAP = 100; //function prototypes bool openFile(ifstream &); void readData(ifstream &, int [], int &); void printData(const int [], int); void sum(const int[], int); void removeItem(int[], int &, int); int main() { ifstream inFile; int list[CAP], size = 0; if (!openFile(inFile)) { cout << "Program terminating!! File not found!" << endl; return -1; } //read the data from the file readData(inFile, list, size); inFile.close(); cout << "Data in file:" <<...

  • using the source code at the bottom of this page, use the following instructions to make...

    using the source code at the bottom of this page, use the following instructions to make the appropriate modifications to the source code. Serendipity Booksellers Software Development Project— Part 7: A Problem-Solving Exercise For this chapter’s assignment, you are to add a series of arrays to the program. For the time being, these arrays will be used to hold the data in the inventory database. The functions that allow the user to add, change, and delete books in the store’s...

  • howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE]...

    howthe   output   of   the   following   4   program segments (a)    const int SIZE=8;    int values[SIZE] = {10, 10, 14, 16, 6, 25, 5, 8};    int index;    index=0;    res = values[index];    for (int j=1; j<SIZE; j++)    {        if (values[j] > res)        {            res = values[j];            index = j;        cout << index << res << endl;        }    }    cout <<...

  • A library maintains a collection of books. Books can be added to and deleted from and...

    A library maintains a collection of books. Books can be added to and deleted from and checked out and checked in to this collection. Title and author name identify a book. Each book object maintains a count of the number of copies available and the number of copies checked out. The number of copies must always be greater than or equal to zero. If the number of copies for a book goes to zero, it must be deleted from the...

  • Please provide original Answer, I can not turn in the same as my classmate. thanks In...

    Please provide original Answer, I can not turn in the same as my classmate. thanks In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a “next” pointer. Textbook Type Attribute String title String author String ISBN Textbook* next Textbook Type Attribute String title String...

  • I wrote this code but there’s an issue with it : #include <iostream> #include <vector&...

    I wrote this code but there’s an issue with it : #include <iostream> #include <vector> #include <string> #include <fstream> using namespace std; class Borrower { private: string ID, name; public: Borrower() :ID("0"), name("no name yet") {} void setID(string nID); void setName(string nID); string getID(); string getName(); }; void Borrower::setID(string nID) { ID = nID; } void Borrower::setName(string nname) { name = nname; } string Borrower::getID() { return ID; } string Borrower::getName() { return name; } class Book { private: string...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT