Write a stub for each member function of class book

Assignment Help DOT NET Programming
Reference no: EM132096098

PLEASE HELP IN

This Program is C++ (Microsoft Visual Studio)

Consider the following scenario: Company allForSale.com is an online store that sells several types of products online including books, electronic items (cell phones, notebooks, laptops, cameras, etc), and small home appliances.

The company hires you to write a program to manage its inventory. Your first thought is to create a class to represent each type of inventory sold by the company.

However, you quickly realize that all inventory items have several common attributes such as product description, price, and quantity on hand. So you decide to use the InventoryItem class defined in Lab 4 as a based class (with necessary changes).

In this lab, you will (1) modify class InventoryItem to include a price data member and (2) defined a derived class of InventoryItem to represent books.

Task 1: Add a data member to class InventoryItem

Exercise 1.Add a data member to class InventoryItem to represent the item's price

Exercise 2.Update the class constructors to initialize the price data member

Exercise 3.Add an accessor (getPrice) that returns the value of price and a mutator to set it (setPrice).

Exercise 4.Use the new accessor function to test the class constructors and setPrice().

Exercise 5.Update the display() member function to display inventory item price, in addition to the other data members. (Note: make sure to change its name to display() if you haven't done so already).

Exercise 6.Update the read() member function to read price, in addition to description and quantity on hand from an input stream. Note: Make sure to change its name to read(ifstream &). You may assume a simplified CSV (Comma Separated Values) format for the input: every line has the data values of one inventory item separated by commas. Example: Iphone 6, 33, 599.00

Samsung Galaxy s6, 21, 439.50

You may use the following function to read data for one inventory item:

void InventoryItem::read(ifstream &inFile)

{ string line;

getline(inFile, line, ',');

setDescription(line);

int q; double p; char comma; inFile >> q;

setQuantityOnHand(q);

inFile >> comma;

inFile >> p;

setPrice(p);

inFile.ignore(100, '\n');

}

Below is a UML class diagram of class InventoryItem:

InventoryItem

- description: string

- qantityOnHand:

int - price: double

+ InventoryItem()

+ InventoryItem(string, int, double)

+ getDescription() const: string

+ getQuantityOnhand() const: int

+ getPrice() const : double

+ setDescription(string): void

+ setQuantityOnhand(int): void

+ setPrice(double): void

+ display() const: void

+ read(ifstream &): void

Task 2: Derived class Book

Exerise 1. Declare a class Book as a derived class of InventoryItem. You only need to do the class specification in this task. Write a specification in a header file called Book.h. Make sure to include InventoryItem.h file from Task 1. Exerise 2. class Book should have the following data members:

-Title

-Name of author (assume only one author for now)

-Publisher

Exerise 3. Write the prototypes of the following member functions in class Book

-A default constructor that initializes the above data members to default values of your choice and uses the default constructor of the base class

- Accessor and mutator functions for book title, author, and publisher

-A parametrized constructor that initializes all data members including description, price, and quantity on hand. Remember to use as much of the code from the base class and to use the set functions to set data members.

- A member function display to display all attributes of a book

- A member function read to read all attributes of a book from an input stream.

Exerise 4. Draw a UML class diagram of class Book

Task 3: Incremental implementation and testing

Exercise 1. Write a stub for each member function of class Book. You can this either in Book.h or in a separate implementation file (Book.cpp). A function stub consists of the function header and an empty body if the function is a void function. For valuereturning functions, have the function return a dummy value.

Exercise 2.Write a driver program to test your new class. In function main() of the driver program, declare one instance of class Book. Build your project and fix all syntax errors.

Exercise 3.Incrementally implement the member functions of class Book. Each time you implement a function test it. Start with the set functions, then implement the get functions. Use the get function to test the set functions. Then implement and test the constructors. Finally, implement and test the display and read member functions. When implementing your class, you need to adhere to the following practices:

1. Use code from the base class whenever possible

2. Any changes to the data members should be done using the class set functions.

Task 4: Final testing of Book class

Exercise 1. Use the driver program below to test your Book class. Make sure to include the header file with the Book class you defined in the previous tasks.

//*******************************************************

// Driver program to test class Book.

// Note that it uses the vector class from the Standard Template Library

// to create a dynamic list of Book instances

#include <iostream>

#include <iomanip>

#include <fstream>

#include <string>

#include <vector>

#include "Book.h"

using namespace std;

int main()

{

ifstream file("data.csv"); //Assume the name of input file is "data.csv"

if (!file)

{

cerr <<"Can't open file "<<

"data.csv"<< endl;

return (EXIT_FAILURE);

}

vector<Book>bookList; Book

temp; while (file)

{ temp.read(file);

bookList.push_back(temp);

}

for (int i = 0; i < bookList.size(); ++i)

bookList[i].display();

system("pause");

return 0;

}

Demo your lab using the driver program above

Reference no: EM132096098

Questions Cloud

Interval for all cds sold at the store : The mean price is $7.95 with a standard deviation of $1.30. Construct a 95% confidence interval for all CDs sold at the store.
Confidence interval for the proportion of golfers : A survey of 1500 golfers showed that 225 of them are left-handed. Construct a 95% confidence interval for the proportion of golfers who are left-handed.
What is the smallest number of internal nodes of a heap : What is the smallest number of internal nodes of a heap of height h? Explain your answer by drawing a heap.
Difference between a parameter and a statistic : What is the difference between a parameter and a statistic? Describe an example. Finally, there are "adjustments" that statisticians
Write a stub for each member function of class book : Write a stub for each member function of class Book. You can this either in Book.h or in a separate implementation file (Book.cpp).
Difference between the mean and the median : What is the difference between the mean and the median and which would you report if you had a skewed set of data to describe the central tendency?
Properties of moment generating functions : a. Use the properties of moment generating functions to show that aX+b ~ N(aµ +b, as).
Create a program vacationbooker that books hotels : Create a program VacationBooker that books hotels for Hawaiian vacations.
Math course and writing course independent : Are the events students enrolled in math course and writing course independent?

Reviews

Write a Review

DOT NET Programming Questions & Answers

  Create a shopping cart in asp

The users will use a browser to access the on-line store. The web server software for the production web server is Windows 2003 Server /IIS6.

  Create a typed dataset

We will create a typed dataset, a Data Layer class, several functions to access the data, and a connection to a database. We also will add a search form to allow the user to search records in the database and display the results of that search

  Create program to meet the specification of companys request

Using Visual Studio and C# programming concepts, create a program to meet the specifications of the company's request.

  Crm system

Development of a simple sales and invoice component where a customer fills out a form on a web page to request a truck delivery and then receives an online invoice in PDF format.

  List advantages of asp

List advantages of ASP (SaaS) hosting services for ERP deployment. What is it about SaaS hosting services that make it very attractive for small to mid-sized corporations?

  Add insert and edit menu options - insert will allow the

add insert and edit menu options - insert will allow the user to insert a new account in a position of his choice -

  How can you enhance linq to sql application performance

Describe how can you enhance LINQ to SQL application performance? Provide examples. Ajax calls can be in form of a GET or POST. Which of these two options are you more likely to use over the other? Consider performance issues in your decision.

  Create a spaceship object to populate a listview

You will create an application in C# Windows Forms that uses a dialog to create a spaceship object to populate a ListView.

  1- true or false tomcat allows you to deploy multiple java

1- true or false tomcat allows you to deploy multiple java web applications in your web apps folder in your home

  Develop a new point-of-sales system

Develop a new point-of-sales system to help them to keep track of and handle their daily orders - Develop a window application

  Programming uml

programming uml

  Create a program that prompts the user for a name

Write a program that prompts the user for a name, Social Security number, hourly pay rate, and number of hours worked. Display the information that was input by the user.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd