Concept explainers
A harder version of
■ 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.
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
C Programming Language
C How to Program (8th Edition)
Modern Database Management (12th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
- in c++ write aprogram to Create a class Rectangle with length and breadth as private data members and also provide the following member functions: getdata(): gets the length and breadth of rectangle. calarea(): return the area of the rectangle. calperi(): return the perimeter of the rectangle. issquare(): return true if the rectangle is squarearrow_forwardAssignment 7 B: Battle! Language is in C++ (pictures include the sample output) Recreate a basic battle system from a video game. You will create a character and then use it to battle a computer generated opponent. There are three possible classes, with the following attributes: Sword Fighter Dance BattlerHP: 120Attack: 40Defense: 0.20ClassID: 1 Unicorn SorcererHP: 80Attack: 35Defense: 0.60ClassID: 2 Dance BattlerHP: 100Attack: 20Defense: 0.42ClassID: 3 You will create a NPC class that has these three attribute. It should also have an attribute for Name.You will then create the following methods in the NPC class: A constructor that takes in a Name string and a ClassID int. It should use the value of the ClassID to assign values to the other attributes (using the chart above) Getter methods for all five attributes, and a Setter method for HP that subtractsthe object’s HP by the value passed in. calculateAttack◦ This method returns a float value. It takes in a float that represents…arrow_forwardAssignment 7 B: Battle! Language is in C++ (pictures include the sample output) Recreate a basic battle system from a video game. You will create a character and then use it to battle a computer generated opponent. There are three possible classes, with the following attributes: Sword Fighter Dance BattlerHP: 120Attack: 40Defense: 0.20ClassID: 1 Unicorn SorcererHP: 80Attack: 35Defense: 0.60ClassID: 2 Dance BattlerHP: 100Attack: 20Defense: 0.42ClassID: 3 You will create a NPC class that has these three attribute. It should also have an attribute for Name.You will then create the following methods in the NPC class: A constructor that takes in a Name string and a ClassID int. It should use the value of the ClassID to assign values to the other attributes (using the chart above) Getter methods for all five attributes, and a Setter method for HP that subtractsthe object’s HP by the value passed in. calculateAttack◦ This method returns a float value. It takes in a float that represents…arrow_forward
- Data Structuresarrow_forwardIn C++ Q1.) Write a Review class that has: • These private data members: • string user: ID of the user • string item: ID of the item • double paid: the price of the item that the user buys • double rating: the rating that the user gives to the item • string review: the review content that the user gives to the item • These public member functions: • A default constructor to set all instance variables to a default value • A parameterized constructor (i.e., a constructor with arguments) to set all instance variables • A method for getting/setting the instance variables. • A method for printing the Review's information.arrow_forwardclassarrow_forward
- The class definition for an Item is given in the image UML diagram below Note: getInfo() returns a string containing ALL of the state information neatly organized. Part 1: Create a class based on the specification above. Reminder: – means private and + means public. Part 2: a)Write a function/method called “addItem” that takes: An array of items The number of items in the array An integer representing a barcode A string representing the name of an item A string representing the description of an item A double value representing the price The function must create and add the item to the array if there is space. The function must return “true” if the addition was successful and “false” otherwise. b)Write a function/method called “listItems” that takes: An array of items The number of items in the array The function must return a string containing the information on each item in the array. c)Write a function called “pricelookup” that takes : An array of items The number of…arrow_forwardIn C++ create a program that acts like a bank account. It asks the user whether to deposit or withdraw. That has 3 classes. The first class must be a generic class that holds basic info deposit, withdraw, calculate monthly interest rate, and a monthly service fee.The second class must be a savings account class that if the savings account falls below $25 it becomes inactive. The final class must be a checking account if someone withdraws more than what they have a service charge of $15 is added and go into a negative balance. The output should display the basic information how much someone deposited or withdrew and their monthly interest rate.arrow_forwardC++arrow_forward
- 1. Following the UML diagrams you designed, code the class 2. Write a test program to test the class you coded in 2.arrow_forward1. Write the PYTHON Programs for the following exercises 2. For each program, you need to write: Comments for all the values, constants, and functions IPO Variables Pseudocode A. Employee and ProductionWorker Classes Write an Employee class that keeps data attributes for the following pieces of information:Employee nameEmployee number Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information:Shift number (an integer, such as 1, 2, or 3)Hourly pay rateThe workday is divided into two shifts: day and night. The shift attribute will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write the appropriate accessor and mutator methods for each class.Once you have written the classes, write a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of…arrow_forwardPythonarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning