Antique Class
Each Antique object being sold by a Merchant and will have the following attributes:
And will have the following member functions:
<Antique.name>: $<price.2digits>
Merchant Class
A Merchant class will be able to hold 10 different Antique objects and interact with the user to sell to them. It should include the following attributes:
And will have the following member functions:
You have successfully haggled and everything is 10% off.
Customer cannot haggle more than once. If he tries to haggle more than once, it will print the following:
Sorry, you have already haggled.
The code is below:-
#include <iostream>
#include <string>
using namespace std;
class Antique { // The class
public: // Access specifier
string name; // Attribute (string variable)
float price; // Attribute (float variable)
Antique(){
name="";
price = 0;
}
string getName(){
return name;
}
void setName(string userName){
name = userName;
}
float getPrice(){
return price;
}
void setPrice(float itemPrice){
price = itemPrice;
}
string toString(){
float value = (int)(price * 100 + .5);
float temp1 = (float)value / 100;
string temp = "Name: "+name+" Price: "+ to_string(temp1);
return temp;
}
};
class Merchent{
Antique *arr;
int *quantities;
float revenue;
public:
Merchent(Antique a[10],int q[10]){
arr = a;
quantities = q;
revenue=0;
}
int haggleUsed = 0;
void haggle() {
if (haggleUsed == 1) { // checking if it's value if 1 then not changing anything
cout<<"Sorry, you have already haggled."<<endl;
} else {
for (int i = 0; i < 10; i++) { // else decreasing the price by 10 percent
float temp = arr[i].getPrice();
temp = temp - (float) (temp * 0.10);
arr[i].setPrice(temp);
cout<<"haggle "<<arr[i].getPrice()<<endl;
haggleUsed = 1;
}
}
}
};
int main() {
Antique an[10];
an[0].setName("Rishab");
an[0].setPrice(45.56);
an[1].setName("qwert");
an[1].setPrice(5.56);
an[2].setName("zxcv");
an[2].setPrice(74.56);
an[3].setName("wscde");
an[3].setPrice(65.56);
an[4].setName("polkij");
an[4].setPrice(25.56);
an[5].setName("yhnmju");
an[5].setPrice(98.56);
an[6].setName("efbrgn");
an[6].setPrice(64.56);
an[7].setName("fjbgh");
an[7].setPrice(10.56);
an[8].setName("yhjur");
an[8].setPrice(35.56);
an[9].setName("asdbteh");
an[9].setPrice(30.56);
int quantity[]={1,2,3,4,5,6,7,8,9,10};
Merchent mr(an,quantity);
mr.haggle();
for(int i=0;i<10;i++){
cout<<an[i].getPrice()<<endl;
}
mr.haggle();
}




FOR ANY OTHER QUERY PLEASE COMMENT
Antique Class Each Antique object being sold by a Merchant and will have the following attributes:...
IN c++ i post this question 5 times. hope this time somebody answer.. 16.5 Homework 5 OVERVIEW This homework builds on Hw4(given in bottom) We will modify the classes to do a few new things We will add copy constructors to the Antique and Merchant classes. We will overload the == operator for Antique and Merchant classes. We will overload the + operator for the antique class. We will add a new class the "MerchantGuild." Please use the provided templates...
I am writing a program that has a class called merchant however
when I try to initialize a merchant object which takes in as
parameters two arrays something is going wrong as I cannot call the
functions within the merchant.cpp. Not sure where the problem
is?
Merchant merch(Antique antiques[], int quantities[]); //cout << "Enter in budget: $"; //cin >> budget; cin >> selection; switch (selection) { case '1': merch.haggle(); case '2': merch.printMenu(); case '3': merch.selectAntique(); case '4': default: break; #ifndet...
C++ please! OVERVIEW This homework builds on HW4. We will modify the classes to do a few new things We will add copy constructors to the Antique and Merchant classes. We will overload the == operator for Antique and Merchant classes. We will overload the + operator for the antique class. We will add a new class the "MerchantGuild." Please use the provided templates for the Antique and Merchant classes, as we simplified their functionality for this homework. Also, you...
The object class should be a Student with the following attributes: id: integer first name: String last name: String write the accessors, mutators, constructor, and toString(). In your main test class you will write your main method and do the following things: Create an array of Student objects with at least 5 students in your array. Write a sort method that must be your original work and included in the main class. The sort method will sort based on student...
Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....
Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...
Additional info is this will use a total of four classes Book,
BookApp, TextBook, and TextBookApp.
Also uses Super in the TextBook Class section.
Problem 1 (10 points) Вook The left side diagram is a UML diagram for Book class. - title: String The class has two attributes, title and price, and get/set methods for the two attributes. - price: double Вook) Book(String, double) getTitle(): String setTitle(String): void + getPrice() double setPrice(double): void toString() String + The first constructor doesn't...
Using your Games class, create an array of Games’ objects on the heap (three for the SIZE) and then pass the pointer that points to that array to a function that loads it up with the same info from part A. Print the array’s values using the pointer. Make sure the program properly uses the accessors and mutators. When completed the program should cleanup. //This is my Games class class Games { private: string gameName, gameType; float gameCost; public: //constructor...
When answering this question, can you please specify what you name your files? Thank you! Write a Java application, and an additional class to represent some real-world entity. Keep in mind that a class is a model in code of something real or imagined, which has attributes (member variables) and behaviors (member methods). The class will: a. Create a total of 5 member variables for the class, selecting the appropriate data types for each field. For example, a class to...