Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS ALL WRITTEN IN C++ o o o o Store and print a list of bottles that is part of someone's collection. You will

image text in transcribedimage text in transcribed

THIS IS ALL WRITTEN IN C++

o o o o Store and print a list of bottles that is part of someone's collection. You will get the list of bottles from a text file. I've provided a couple text files for you. We will grade with big.txt. Your text file reading doesn't need to be fancy. The data is space delimited. There is a maximum of 30 records in the file. Make and use a constant for this. You may use the string class for any text variables. Use functions and methods in a logical way. Don't have big functions or methods. Your classes and structures must: Each have their own .h and.cpp. Only methods that are 1 line may be inline (in the.h) Be const correct. Don't underestimate the work of this the first-time round. (It will be easier if you make it a habit and just start const correct.) Your.h must either use #ifndef or #pragma once. If you use #pragma once you must provide a comment that describe how it works and demonstrates that you understand it. Note: Since you are adding .h and.cpp for your classes you will be pushing new files to github. You can do it! You will have at least 1 class to store the information about a single bottle. The information we care about is: The color-One word to describe the color. The type - One word to describe the type of bottle: i.e. flask, syrup. The age - an integer to indicate how old the bottle is. The value-a double to indicate how much the bottle is worth. To stay const correct you will need getter functions for all the member data. These functions can be defined in the .h since they will only be a line long. A print method that prints a single bottle. A default constructor that blanks or zeros all the data. A constructor that takes all 4 pieces of data (color, type, age, value) and calls the initialization function below. o o o O o You will need setters for all your data or a method to initialize a whole bottle. As a hint here is the signature from mine: void init (const string & color, const string & cat, int age, double value); You will have another class or structure to represent the collection of bottles. You will fill the collection as you read the file and add bottles. It has the following member data. . An array for your bottles. It is at most 30 bottles (see note above about file size.) . An integer to indicate how many bottles you have at this moment. (So, for example the test.txt file has 7 as the size. A method to provide the total value of the collection. This will simply loop through the array of bottles and sum the values. A method to print the collection. It will also print the count of bottles and the total value. o o o o o Store and print a list of bottles that is part of someone's collection. You will get the list of bottles from a text file. I've provided a couple text files for you. We will grade with big.txt. Your text file reading doesn't need to be fancy. The data is space delimited. There is a maximum of 30 records in the file. Make and use a constant for this. You may use the string class for any text variables. Use functions and methods in a logical way. Don't have big functions or methods. Your classes and structures must: Each have their own .h and.cpp. Only methods that are 1 line may be inline (in the.h) Be const correct. Don't underestimate the work of this the first-time round. (It will be easier if you make it a habit and just start const correct.) Your.h must either use #ifndef or #pragma once. If you use #pragma once you must provide a comment that describe how it works and demonstrates that you understand it. Note: Since you are adding .h and.cpp for your classes you will be pushing new files to github. You can do it! You will have at least 1 class to store the information about a single bottle. The information we care about is: The color-One word to describe the color. The type - One word to describe the type of bottle: i.e. flask, syrup. The age - an integer to indicate how old the bottle is. The value-a double to indicate how much the bottle is worth. To stay const correct you will need getter functions for all the member data. These functions can be defined in the .h since they will only be a line long. A print method that prints a single bottle. A default constructor that blanks or zeros all the data. A constructor that takes all 4 pieces of data (color, type, age, value) and calls the initialization function below. o o o O o You will need setters for all your data or a method to initialize a whole bottle. As a hint here is the signature from mine: void init (const string & color, const string & cat, int age, double value); You will have another class or structure to represent the collection of bottles. You will fill the collection as you read the file and add bottles. It has the following member data. . An array for your bottles. It is at most 30 bottles (see note above about file size.) . An integer to indicate how many bottles you have at this moment. (So, for example the test.txt file has 7 as the size. A method to provide the total value of the collection. This will simply loop through the array of bottles and sum the values. A method to print the collection. It will also print the count of bottles and the total value. o

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

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions

Question

Identify four applications of HRM to healthcare organizations.

Answered: 1 week ago