Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#define BOTTLE_H #ifndef BOTTLE_H /// to ensure one time compilation #include // string operation #include using namespace std; #include // to file operation class bottle

#define BOTTLE_H #ifndef BOTTLE_H /// to ensure one time compilation

#include // string operation

#include using namespace std;

#include // to file operation

class bottle { public: bottle(); bottle(const string& color, const string& type, int age, double value); inline const string getColor() {return m_color;} inline const string getType() {return m_type;} inline const int getAge() {return m_age;} inline const double getValue() {return m_value;}

void print(); private: string m_color; string m_type; int m_age; double m_value; }; #endif

CPP of bottle

#include "bottle.h" bottle::bottle() { m_color = ""; m_type = ""; m_age = 0; m_value = 0.0; } bottle::bottle(const string& color, const string& type, int age, double value) { m_color = color; m_type = type; m_age = age; m_value = value; } bottle::print() { cout << m_color << '\t' << m_type << '\t' << m_age << '\t' << m_value << endl; }

// CST126_2_91.cpp : This file contains the 'main' function. #include "bottle.h" #include // string operation #include // string stream operation #include #include using namespace std; #define maximum 30 //bottle globalArray[maximum]; bool OpenInputFile(ifstream& input_file, string filename); void readfile(ifstream& input_file); bool OpenInputFile(ifstream& input_file, string filename) {

input_file.open(filename);

if (input_file.fail()) { cout << "ERROR: Unable to open file : " << filename << endl; return false; } else { cout << "Opened file " << filename << endl; readfile(input_file); return true; } } void readfile(ifstream& infile) { bottle[maximum]; string color; string category; int age; double value; int temp; int count = 0; //While not end of file & less then maximum infile >> color; infile >> category; infile >> age; infile >> value; //create temp bottle bottle.temp(color, category, age, value); //add temp bottle to global structure //globalArray[count] = temp; //count++; //endwhile //testing read,constructor,print functions temp.print(); }

int main() { string fileName; cout << " Please,Enter the filename = "; cin >> fileName; /// read fillename from user cout << fileName; } // Read from the file and print it out. // add a global array of bottles. The globalness of this is just temporary. // added a collection struct including .h / .cpp // moved my global array / size into the struct. // added a "Add Bottle" function to my collection struct. // add a global variable for my collection. // moved collection variable into the main program and passed it into my file reading function. // Added total value function to collection / added it to print.

I need help setting up the last few steps of my code, my code is written in c++ visual studio. Up above is a list of the last bit to make my display for my work however I am not sure what to do next!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

57. Show that for any three events A, B, and C with P(C) 0,

Answered: 1 week ago