Explanation of Solution
Program:
File name: sale.h
//include libraries
#ifndef SALE_H
#define SALE_H
#include <iostream>
using namespace std;
//using the namespace
namespace salesavitch
{
//create a class
class Sale
{
//define access specifier
public:
//declare the constructors
Sale();
Sale(double thePrice);
//define required methods
double bill() const;
double savings(const Sale& other) const;
//define access specifier
protected:
//declare required variables
double price;
};
//define an overloaded method
bool operator <(const Sale& first, const Sale&
second);
}
#endif // SALE_H
File name: discount.h
//include libraries
#ifndef DISCOUNTSALE_H
#define DISCOUNTSALE_H
#include "sale.h"
//using the namespace
namespace salesavitch
{
//create a class
class DiscountSale : public Sale
{
//define access specifier
public:
//declare the constructors
DiscountSale();
DiscountSale(double the_price, double the_discount);
//Discount is expressed as a percent of the price.
virtual double bill() const;
//define access specifier
protected:
//declare required variable
double discount;
};
}
#endif //DISCOUNTSALE_H
File name: sale.cpp
//include libraries
#include "sale.h"
//using the namespace
namespace salesavitch
{
//define a constructor
Sale::Sale() : price(0)
{}
//define a constructor
Sale::Sale(double the_price) : price(the_price)
{}
//declare a method
double Sale::bill() const
{
//return statement
return price;
}
//declare a method
double Sale::savings(const Sale& other) const
{
//return statement
return ( bill() - other...
Trending nowThis is a popular solution!
Chapter 15 Solutions
Problem Solving with C++ (10th Edition)
- Python:Please read the following. The Game class The Game class brings together an instance of the GameBoard class, a list of Player objects who are playing the game, and an integer variable “n” indicating how many tokens must be aligned to win (as in the name “Connect N”). The game class has a constructor and two additional methods. The most complicated of these, play, is provided for you and should not be modified. However, you must implement the constructor and the add_player method. __init__(self,n,height,width) The Game constructor needs to initialize three instance variables. The first, self.n, simply holds the integer value “n” provided as a parameter. The second, self.board, should be a new instance of the GameBoard class (described below), built using the provided height and width as dimensions. The third, self.players, should be an initially empty list. add_player(self,name,symbol) The add_player method is provided a name string and a symbol string. These two values should be…arrow_forwardI need to create a java program with the following format.arrow_forward1)The program should be written in JAVA. Create a "Car" class that keeps car ids and prices. And create a "Galleries" class that holds the car list for a particular gallery. In this class there should be methods for get / set and print for car name, car number and car list. Adding / Removing Cars to the List in This Class should have methods. And create another method to find and print the IDs of Cars with Car Segment equal to X. (print_id(X)). Car Prices are as follows according to the segments. 0$-19999$ -> Z20000$-29999$ -> Y30000$-44999$ -> T45000$-100000$ -> P Apply the Car list using "Singly Linked List"(Node, newNode, head).arrow_forward
- What is the solution for this question (using java language)arrow_forwardWrite a simple C++ code as I am a beginner.arrow_forward1. How can we write a parameter less Lambda expression? a. Need to pass curly braces to denotes that there are no parameter on left side of the arrow.b. Pass empty set of parentheses on the left side of the arrow.c. In this particular case arrow is not required at all.d. No need to pass anything on the left side of the arrow. 2. Which of the following is NOT true about functional interface in Java? a. It has multiple methods that needs to be implemented.b. Lambda expression implicitly implement the single method inside functional interface.c. If a lambda expression is provided then the method name should not be provided.d. It has only a single method that needs to be implemented.arrow_forward
- This is for my python class, so python code please. This code needs to take inputs from a outside source/program, not for specific examples. Sorry for the confusion. 9.12 LAB: Product class In main.py define the Product class that will manage product inventory. Product class has three attributes: a product code, the product's price, and the number count of product in inventory. Implement the following methods: A constructor with 3 parameters that sets all 3 attributes to the value in the 3 parameters set_code(self, code) - set the product code (i.e. SKU234) to parameter code get_code(self) - return the product code set_price(self, price) - set the price to parameter price get_price(self) - return the price set_count(self, count) - set the number of items in inventory to parameter count get_count(self) - return the count add_inventory(self, amt) - increase inventory by parameter amt sell_inventory(self, amt) - decrease inventory by parameter amtarrow_forwardModify the above code to use the alternative method for multithreading (i.e., implementing the Runnable interface). Name your main class RunnableHelloBye and your subsidiary classes Hello and Goodbye respectively. The fi rst should display the message ‘Hello!’ ten times (with a random delay of 0–2 s between consecutive displays), while the second should do the same with the message ‘Goodbye!’. Note that it will NOT be the main class that implements the Runnable interface, but each of the two subsidiary classes.arrow_forwardI've gotten stuck on this practice problem. I need help figuring this out. You need to make a Pet class that holds the following information as private data members: the name of the pet (e.g. "Spot", "Fluffy", or any word a user enters) the type of pet (e.g. dog, cat, snake, hamster, or any word a user enters) level of hungriness of the pet (2 means hungry, 1 means content, 0 means full) Your class also needs to have the following functions: a default constructor that sets the pet to be a dog named Buddy, with level of hungriness being “content” a parameterized constructor to allow having any type of pet the order of the parameters is: name of the pet, type of pet, hungriness level a PrintInfo function that prints the info for the pet according to the sample output below a TimePasses function that increases the hungry level of the pet by one (unless its hungry level is already 2, meaning hungry). a FeedPet function that changes the hungry level of the pet to 0 (Full) You must…arrow_forward
- A PMC (private military contractor) has contacted you to help write code to control the Security Checkpoints for their company. You must create (in C++) a Checkpoint class with a hidden attributes (Authorized, Guest, Unauthorized), two constructors (a default that sets all access levels to false and an overloaded that sets Authorized and Unauthorized to false and Guest to true for testing purposes) and a method that changes the access level to the next in the sequence (Authorized – Guest – Unauthorized).arrow_forward16. Create a class SubstitutionCipher that implements the interface MessageEncoder, as described in the previous exercise. The constructor should have one parameter called shift. Define the method encode so that each letter is shifted by the value in shift. For example, if shift is 3, a will be replaced by d, b will be replaced by e, c will be replaced by f, and so on. (Hint: You may wish to define a private method that shifts a single character.)arrow_forwardhttps://youtu.be/4hAoK54Pfdc Here is a video regarding the kit component.arrow_forward
- 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