Consider the definition of the class product Type as given in Exercise 8.
Answer the following questions. (1, 2, 3, 5, 7)
Write the definition of the function set so that instance variables are set according to the paramaters. Instance variables quantitieslnStock, price, and discount must be nonnegative.
Write the definition of the function print to output the values of the instance variables.
Write the definition of the function setQuantitiesInStock to set the value of the instance variable quantitiesInStock according to the parameter.
Write the definition of the function updateQuantitiesInStock to update the value of instance variable quantitiesInStock by adding the value of the parameter.
Write the definition of the function getQuantitiesInStock to return the value of instance variable quantitiesInStock.
Write the definition of the function setPrice to set the value of the instance variable price according to the parameter.
Write the definition of the function getPrice to return the value of the instance variable price.
Write the definition of the function setDiscount to set the value of the instance variable discount according to the parameter.
Write the definition of the function getDiscount to return the value of the instance variable discount.
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
- Use the definition of the class productType to answer the questions a,b,c,d, and e pictured below. *class productType is also pictured below *Everything is in C++arrow_forwardRedo Programming Exercise 3 by overloading the operators as nonmembers of the class boxType. Write a test program that tests various operations on the class boxType. Reference: Chapter 11 defined the class boxType by extending the definition of the class rectangleType. In this exercise, derive the class boxType from the class rectangleType, defined in Exercise 1, add the functions to overload the operators +,–, *, ==, !=, <=, <, >=, >, and pre- and post-increment and decrement operators as members of the class boxType. Also overload the operators << and >>. Overload the relational operators by considering the volume of the boxes. For example, two boxes are the same if they have the same volume. Write the definitions of the functions of the class boxType as defined above and then write a test program that tests various operations on the class.arrow_forwardI need the answer as soon as possiblearrow_forward
- SUBJECT: OOPPROGRAMMING LANGUAGE: C++ ADD SS OF OUTPUT TOO. Create a class Student with attributes StudentName, Enrollment, semester, section, course MarksObtained and Grade. Write appropriate constructors, get and set functions for data members. Read data from file and print number of Grade occurrences in the following format: A grade: 2 B grade: 1 C grade: 3 D grade: 2 F grade: 3arrow_forwardWeek One: Introduction to Object oriented Programming Course overview. Reading: Key Differences between Procedural Programming and Object-Oriented Programming (OOP). Chapter One Assignment: Write C++ code to implement void and return type functions. The code should contain more than one function. Use the implemented code to investigate the possibility of the following by indicating them as valid or invalid 1- Returning (directly or indirectly) values using void function. 2- Returning (directly or indirectly) multiple values. 3- Passing an Array to a function. 4- Implementing more than one function with same name. 5- Controlling access to functions. 6- Declaring a variable with multiple data types simultaneously.arrow_forward1. Short questions: a. What is the difference between having a function return type being "const dataType &" and it being "dataType&"? b. When is it necessary to make a function or a class a friend of another class? c. List all who can access: the private member of a class protected member of a class public member of a class d. What is difference between static data and a regular data of a class?arrow_forward
- Solve This ASAParrow_forward1. Fill in the blanks for Questions 1 & 2 a. Instance of a class is called b. functions have same name but different sets of parameters. of arguments in a function call must match c. Number, the parameters in function parameter list and d. functions are defined once and can be used for different data Тypes. 2. Most important attributes of OOP (Object Oriented Programming) are: _ , that is creating new classes from an existing base class. when a program calls a virtual function using base class b. pointers or references to use the same function with different forms/structures.arrow_forwardneed help in c++ code screenshot and outputarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning