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

  Develop web services based application

Develop and test a Web services based application that meets the requirements applying SOA design principles.

  Design style elements in asp

Add drop down lists for modifying the different style elements for the label element that displays the time

  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.

  Inventory management system in c# application

Inventory management system in c# application

  Using .net resources to teach .net

This project will use the .NET framework to produce a set of materials to demonstrate the fundamental principles of .NET. Ideally it should demonstrate some of the principles of the framework e.g. interoperability.

  Prepare a marymount faculty site

Prepare a Marymount faculty site

  Blinky lights

Analysis proving that your code blinks the LEDs at the specified rates.

  Prepare a web application

Prepare a web application that will be used to keep track of patients registering in a hospital.

  Implementing the insurance management system

Implementing the Insurance Management System and implementation of Components as Web Services.

  Describe the characteristics of visual studio 2005

Describe the characteristics of Visual Studio 2005 Visual Studio.Net is a suite of products that includes 4 main languages. Name these languages and outline their use in industries

  What is a connectionstring

What is a ConnectionString. Give a suitable example to illustrate the various part of a ConnectionString

  Prepare a web application for internet service provider

Prepare a Web application and write the code also event planning document base. This web application allows the user to sign up for an Internet service provider for home connectivity.

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