Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 11.4, Problem 24STE
Program Plan Intro
Destructor:
- Destructor is a member function of a class that is called automatically when an object of the class goes out of scope.
- This means that if the program has a local variable that is an object with a destructor, then when the function call ends, the destructor is called automatically.
- Destructors are used to remove any dynamic variables that have been generated by the object so that the memory occupied by these dynamic variables is returned to the freestore.
- Destructors may implement other cleanup tasks as well.
- The name of the destructor must contains a tilde symbol, “~” followed by the name of the class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Task 4. Utility classes
Implement a Menu-Driven program of ArrayList class using the above scenario and perform the
following operations.
a. Create an object of ArrayList class based on the scenario with explanations of the method used.
b. Create a method that will allow inserting an element to ArrayList Class based on the scenario. The
input field must be validated as necessary.
C.
Create a method to delete specific elements in the ArrayList with explanations of the method used.
The following is the specification for the constructor of a EmailFolder class:
/*** Creates a new EmailFolder with the given label** @precondition label != null AND !label.isEmpty()* @postcondition getLabel()==label*/public EmailFolder(String label)
Assume the variable folders is an array list of EmailFolder objects.
Write code that gets the tenth item in the list, assigning it to an appropriate variable. (java)
Using Java
You will write the code to perform the following operations using the ArrayList class:
Implement a Shoe class, encapsulating the concept of a shoe
A shoe has a color, size, and brand.
Implement a ShoeStore class, encapsulating the concept of a shoe store.
Use the ArrrayList of Shoe objects.
Fill the ArrayList object with Shoe objects.
Implement a ShoeSearchEnginge class
Print Shoe objects in the ArrayList.
color: white size: 11 brand: Anne Klein
color: yellow size: 13 brand: Calvin Klein
color: black size: 9 brand: COACH
color: blue size: 5 brand: CLARK
color: black size: 7 brand: Cole Han
color: blue size: 15 brand: FitFlo
color: red size: 9 brand: CLARK
Find all Shoe objects with CLARK as a brand in the ArrayList.
Find the largest size of a Shoe object in the ArrayList.
Chapter 11 Solutions
Problem Solving with C++ (10th Edition)
Ch. 11.1 - Write a function definition for a function called...Ch. 11.1 - What is the difference between a friend function...Ch. 11.1 - Suppose you wish to add a friend function to the...Ch. 11.1 - Prob. 4STECh. 11.1 - Notice the member function output in the class...Ch. 11.1 - Notice the definition of the member function input...Ch. 11.1 - The Pitfall section entitled Leading Zeros in...Ch. 11.1 - Give the complete definition of the member...Ch. 11.1 - Why would it be incorrect to add the modifier...Ch. 11.1 - What are the differences and the similarities...
Ch. 11.1 - Given the following definitions: const int x = 17;...Ch. 11.2 - What is the difference between a (binary) operator...Ch. 11.2 - Prob. 13STECh. 11.2 - Suppose you wish to overload the operator = so...Ch. 11.2 - Prob. 15STECh. 11.2 - Give the definition for the constructor discussed...Ch. 11.2 - Here is a definition of a class called Pairs....Ch. 11.2 - Following is the definition for a class called...Ch. 11.3 - Give a type definition for a structure called...Ch. 11.3 - Write a program that reads in five amounts of...Ch. 11.3 - Change the class TemperatureList given in Display...Ch. 11.3 - Prob. 22STECh. 11.3 - If a class is named MyClass and it has a...Ch. 11.4 - Prob. 24STECh. 11.4 - The following is the first line of the copy...Ch. 11.4 - Answer these questions about destructors. a. What...Ch. 11.4 - a. Explain carefully why no overloaded assignment...Ch. 11 - Modify the definition of the class Money shown in...Ch. 11 - Self-Test Exercise 17 asked you to overload the...Ch. 11 - Self-Test Exercise 18 asked you to overload the...Ch. 11 - Prob. 1PPCh. 11 - Define a class for rational numbers. A rational...Ch. 11 - Define a class for complex numbers. A complex...Ch. 11 - Enhance the definition of the class StringVar...Ch. 11 - Define a class called List that can hold a list of...Ch. 11 - Define a class called StringSet that will be used...Ch. 11 - This programming project requires you to complete...Ch. 11 - Redo Programming Project 6 from Chapter 9 (or do...Ch. 11 - Solution to Programming Project 11.12 To combat...Ch. 11 - Repeat Programming Project 11 from Chapter 10 but...Ch. 11 - Do Programming Project 19 from Chapter 8 except...
Knowledge Booster
Similar questions
- The following is the specification for the constructor of a EmailFolder class: /*** Creates a new EmailFolder with the given label** @precondition label != null AND !label.isEmpty()* @postcondition getLabel()==label*/public EmailFolder(String label) Assume the variable folders is an array list of EmailFolder objects. Write code to remove the first EmailFolder from the list.arrow_forwardThe following is the specification for the constructor of a EmailFolder class: /*** Creates a new EmailFolder with the given label** @precondition label != null AND !label.isEmpty()* @postcondition getLabel()==label*/public EmailFolder(String label) Assume the variable folders is an array list of EmailFolder objects. Write code to add a new EmailFolder to the list.arrow_forwardP8.2 Implement a class Quiz that implements the Measurable interface. A quiz has a score and a letter grade (such as B+). Use the Data class of Exercise P8.1 to process an array of quizzes. Display the average score and the quiz with the highest score (both letter grade and score).arrow_forward
- Write the definitions of the member functions of the classes arrayListType and unorderedArrayListType that are not given in this chapter. The specific methods that need to be implemented are listed below. Implement the following methods in arrayListType.h: isEmpty isFull listSize maxListSize clearList Copy constructor Implement the following method in unorderedArrayListType.h insertAt Also, write a program (in main.cpp) to test your function.arrow_forwardThe following is the specification for the constructor of a EmailFolder class: /*** Creates a new EmailFolder with the given label** @precondition label != null AND !label.isEmpty()* @postcondition getLabel()==label*/public EmailFolder(String label) Assume the variable folders is an array list of EmailFolder objects. Write code that gets the number of items in the list, assigning them to an appropriate variable.arrow_forwardA programmer is designing a program to catalog all books in a library. He plans to have a Book class that stores features of each book: author, title, isOnShelf, and so on, with operations like getAuthor, getTitle, getShelf Info, and set Shelf Info. Another class, LibraryList, will store an array of Book objects. The LibraryList class will include operations such as listAll Books, addBook, removeBook, and searchForBook. The programmer plans to implement and test the Book class first, before implementing the LibraryList class. The program- mer's plan to write the Book class first is an example of (A) top-down development. (B) bottom-up development. (C) procedural abstraction. (D) information hiding. (E) a driver program.arrow_forward
- The question is p8. 2arrow_forwardCreate a Vector2D class with properties x and y and a proper constructor method. Plus, minus and multiplication with a scalar operators should be overloaded. Create a Body class with properties of pos, vel, mass and constructor(float Mass, Vector2D Pos, Vector2D Vel), addForce(Vector2D F) and Move(float dt) methods. Your program should create an array or collection of Bodies, at each time step (dt), calculate forces that bodies exert each other and apply accordingly. Finally, in a 2D space, bodies should move freely based on their properties and applied forces. You can use option buttons or another element to represent bodies and move them inside the form.arrow_forwardTask 1:The first task is to make the maze. A class is created called Maze, in which a 2D array for the maze is declared. Your job is to implement the constructor according to the given javaDoc. When you completed this task, write a set of Junit test case to test your code.As you probably noticed, the maze is defined as a private variable. The second job for you is to write an accessor(getter) method that returns the maze. Other information about what is expected for this method is given in the starter code. public class PE1 { MazedogMaze; /** * This method sets up the maze using the given input argument * @param maze is a maze that is used to construct the dogMaze */ publicvoidsetup(String[][]maze){ /* insert your code here to create the dogMaze * using the input argument. */ }arrow_forward
- Question 1 Question 1 (12 marks) Not yet This question tests your ability to use: Polymorphism and interface answered Marked out of > 12.00 o Payment P Flag question OExam 1 D - static void constructList(ArrayList alist) - static void displayList(ArrayList alist) D - static void lambdaAnalysis(ArrayListsPayment> alist) O + static void main(Stringl args) > O Usefullnfo is O LoanLender O SIMUOW is O SIMUOW_1 > A AreaFocus A SECURITY A BIGDATA A MULTIMEDIA O SIMUOW F O SIMUOW_2 A BBIS In this question, you will explore two un-related tasks. Two types of persons need to make рayment: - Class LoanLender describes a loan. For a loan, we have a maximum limit for example 100K, and an interest rate, for example 7% - Class SIMUOW describes a student who needs to pay school fees depending on the number of areas of focus. Students can take at most two areas of focus. For example, per area of focus cost is 5K per term, and project's cost is 10K. The University gives 5% discount to students who…arrow_forward3.25 Fixed Sized Deque Your task is to create an implementation of the Java Deque interface that can only hold N items where N is a number passed into the constructor. Note that most (if not all) of the unit tests rely on the method object[] toArray() inherited from Collection. Therefore, you must make sure you implement that method correctly in order to get most of the points. 301664.1524810.gpazay7 LAB АCTIVITY 3.25.1: Fixed Sized Deque 0/ 70 Submission Instructions Compile command javac FixedsizedDeque.java -xlint:all -encoding utf-8 We will use this command to compile your code Upload your files below by dragging and dropping into the area or choosing a file on your hard drive. FixedSizedDeque.java Drag file here or Choose on hard drive.arrow_forward4. Consider the following statement, which is intended to create an ArrayList named theater_club to store elements of type Student. Assume that the Student class has been properly defined and includes a no-parameter constructor. ArrayList theater_club = new /* missing code */; Which choice can replace /* missing code */ so that the statement compiles without error? (A) Student() (C) ArrayList(Student) (E) ArrayList() 5. Consider the following code segment. System.out.println(nums); (B) Student ArrayList() (D) ArrayList() ArrayList nums = new ArrayList(); nums.add(new Integer(37)); nums.add(new Integer(3)); nums.add(new Integer(0)); nums.add(1, new Integer(2)); nums.set(0, new Integer(1)); nums.remove(2); What is printed as a result of executing the code segment? (A) [1, 2, 0] (B) [1, 3, 0] (C) [1, 3, 2] borbruong bus xo (3) bns kol (0) 6032221 (D) [1, 37, 3, 0] trampes godba SEJLED 19 sh (E) [37, 0, 0] 520 jensidarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education