Question
#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
#include
#include
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started