bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 13, Problem 5PP

A harder version of Programming Project 4 would be to write a class named List, similar to Project 4, but with all the following member functions:

■    Default constructor, List();

■    double List::front();f which returns the first item in the list

■    double List::back();, which returns the last item in the list

■    double List::current();t which returns the “current" item

■    void List::advance();t which advances the item that current() returns

■    void List::reset(); to make current() return the first item in the list

■    void List::insert(double afterMe, double insertMe);, which inserts insertMe into the list after afterMe and increments the private: variable count.

■    int size();which returns the number of items in the list

■    friend istream& operator <<(istream& ins, double writeMe);

 The private data members should include the following:

  node* head;

  node* current;

  int count;

 and possibly one more pointer.

 You will need the following struct (outside the list class) for the linked list nodes:

  struct node

  {

  double item;

  node *next;

  };

 Incremental development is essential to all projects of any size, and this is no exception. Write the definition for the List class, but do not implement any members yet. Place this class definition in a file list.h. Then #include “list.h” in a file that contains int main(){}.Compile your file. This will find syntax errors and many typographical errors that would cause untold difficulty if you attempted to implement members without this check. Then you should implement and compile one member at a time, until you have enough to write test code in your main function.

Blurred answer
Students have asked these similar questions
IN C++, Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables - a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for each instance variable. In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to0. Write a test app named InvoiceTest that demonstrates class Invoice's capabilities.
dayType Class We will be working on a project that designs a class calendarType, so that a client program can use this class to print a calendar for any month starting Jan 1. 1900. An example of the calendar for September 2019 is:                                  September 2019  Sun     Mon     Tue     Wed     Thu     Fri     Sat      1         2          3          4          5        6        7       8        9         10         11       12       13      14    15      16        17        18        19      20      21 22     23        24         25        26      27      28  29     30       31 We will develop several classes which will work together to create a calendar. The first of these classes is called dayType which will manipulate a day of the week. The class dayType will store a day, such as Sun for Sunday. The class should be able to perform the following operations on an object of type dayType: a. Set the day. b. Print the day. c. Return the day. d. Return the next day. e.…
The base class Pet has attributes name and age. The derived class Dog inherits attributes from the base class Pet class and includes a breed attribute. Complete the program to: Create a generic pet, and print the pet's information using print_info(). Create a Dog pet, use print_info() to print the dog's information, and add a statement to print the dog's breed attribute. Ex: If the input is: Dobby 2 Kreacher 3 German Schnauzer the output is: Pet Information:      Name: Dobby      Age: 2      Pet Information:      Name: Kreacher      Age: 3      Breed: German Schnauzer code to be used: python class Pet:    def __init__(self):        self.name = ''        self.age = 0     def print_info(self):        print('Pet Information:')        print('   Name:', self.name)        print('   Age:', self.age) class Dog(Pet):    def __init__(self):        Pet.__init__(self)         self.breed = '' my_pet = Pet()my_dog = Dog() pet_name = input()pet_age = int(input())dog_name = input()dog_age =…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY