Question

In: Computer Science

Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private...

  1. Create a class named UsedFurnitureItem to represent a used furniture item that the store sells.
  2. Private data members of a UsedFurnitureItem are:
    1. age (double) // age in years – default value for
    2. brandNewPrice (double) // the original price of the item when it was brand new
    3. description (string) // a string description of the item
    4. condition (char) // condition of the item could be A, B, or C.
    5. size (double) // the size of the item in cubic inches.
    6. weight (double) // the weight of the item in pounds
  3. Public member functions of a UsedFurnitureItem
    1. Constructors – default and overloaded [default values: age = 1.0, brandNewPrice = 10.00, description = “Not available”, condition = ‘A’, size = 1.0, weight = 1.0]
    2. Accessors (getters)
    3. Mutators (setters) – You should ensure that invalid (zero or negative) values do not get assigned to age, brandNewPrice, size or weight data members. An invalid character (other than ‘A’, ‘B’ or ‘C’) should not be allowed to be assigned to the condition data member

Solutions

Expert Solution

Explanation:

Here is the class UsedFurnitureItem with all the appropriate variables, getters , setters and constructors defined as mentioned above:

Code:

class UsedFurnitureItem
{
double age;
double brandNewPrice;
string description;
char condition;
double size;
double weight;
  
public:
UsedFurnitureItem()
{
age = 1.0;
brandNewPrice = 10.00;
description = "Not available";
condition = 'A';
size = 1.0;
weight = 1.0;
}
  
  
UsedFurnitureItem(double a, double b, string d, char c, double s, double w)
{
age = a;
brandNewPrice = b;
description = d;
condition = c;
size = s;
weight = w;
}
  
double getAge()
{
return age;
}
  
double getBrandNewPrice()
{
return brandNewPrice;
}
  
string getDescription()
{
return description;
}
  
char getCondition()
{
return condition;
}
  
double getSize()
{
return size;
}
  
double getWeight()
{
return weight;
}
  
void setAge(double a)
{
if(a>0)
age = a;
}
  
void setBrandNewPrice(double b)
{
if(b>0)
brandNewPrice = b;
}
  
void setDescription(string d)
{
description = d;
}
  
void setCondition(char c)
{
if(c=='A' || c=='B' || c=='C')
condition = c;
}
  
void setSize(double s)
{
if (s>0)
size = s;
}
  
void setWeight(double w)
{
if (w>0)
weight = w;
}
  
};

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!


Related Solutions

Write a class named RetailItem that holds data about an item in retail store.
Python 3Your program will have 2 classes:A) RetailItem ClassWrite a class named RetailItem that holds data about an item in retail store.Attributes: The class should store following data in attributes:>item_Name> PriceMethods:> RetailItem class’s __init__ method should accept an argument for each attribute.> RetailItem class should also have accessor and mutator methods for each attributeB) MainMenu ClassAttributes: The class should store following data in attributes:> List of RetailItem Objects: InventoryMethods:> createInventory(): method to create three RetailItem Objects store in list Inventory...
The Account class Create a class named Account, which has the following private properties:
in java The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber (), getBalance (), setBalan newBalance). There is no setNumber () once an account is created, its account number cannot change. Now implement these methods: void deposit (double amount) and void withdraw (double amount). For both these methods, if the amount is less than...
The Account class Create a class named Account , which has the following private properties:
 The Account class Create a class named Account , which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNunber(), getBalance(), setBalance (double newBalance) . There is no setNunber() - once an account is created, its account number cannot change. Now implement these methods: void deposit (double anount) and void withdraw(double anount). For both these methods, if the amount is less than zero,...
Invoice Class - Create a class called Invoice that a hardware store might use to represent...
Invoice Class - Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables—a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. If the quantity passed to the constructor is...
Invoice Class - Create a class called Invoice that a hardware store might use to represent...
Invoice Class - Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables—a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. If the quantity passed to the constructor is...
3.12 (Invoice Class) Create a class called Invoice that a hardware store might use to represent...
3.12 (Invoice Class) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables-a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for...
The Account class Create a class named Account, which has the following private properties: number: long...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement deposit(double amount) and withdraw(double amount) methods. If the amount is less than zero,...
The Account class Create a class named Account, which has the following private properties: number: long...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement deposit(double amount) and withdraw(double amount) methods. If the amount is less than zero,...
The Account class Create a class named Account, which has the following private properties: number: long...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement these methods: void deposit(double amount) and void withdraw(double amount). For both these methods,...
with PHP Create a class called Invoice that a hardware store might use to represent an...
with PHP Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables — a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT