Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
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
Object Oriented Programming in JAVA   You are part of a team writing classes for the different game objects in a video game. You need to write classes for the two human objects warrior and politician. A warrior has the attributes name (of type String) and speed (of type int). Speed is a measure of how fast the warrior can run and fight.  A politician has the attributes name (of type String) and diplomacy (of type int). Diplomacy is the ability to outwit an adversary without using force. From this description identify a superclass as well as two subclasses. Each of these three classes need to have a default constructor, a constructor with parameters for all the instance variables in that class (as well as any instance variables inherited from a superclass) accessor (get) and mutator (set) methods for all instance variables and a toString method. The toString method needs to return a string representation of the object. Also write a main method for each class in which that class is…
Vending Machine
Activity - Abstract Class An English teacher wants to find assessment mark of all the students in his course. Write a java program to find assessment mark of the students using following instructions. Save the project/file as StudentAbstract. A) Abstract Class name: Assessment Abstract Member Method: - to calculate and return total score totalScore() B) Class name: English extends Assessment Member variables: QuizMark, PracticeTest, ListeningMark Member Method : - Constructor to initialize member variables - to calculate and return total score totalScore QuizMark + PracticeTest*0.25 + %3D ListeningMark/2 C) Controlling class : StudentAbstract - To create an object of English class - To print totalScore of the English
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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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