Question

In: Computer Science

Write a C++ program that design a class definition to be put in a header file...

Write a C++ program that design a class definition to be put in
a header file called fizzjazz.h A store sells online FizzJazz
which are sound tones made by famous bands. For each FizzJazz,
the store wants to keep track of the following attributes:

* title - the name of the sound tone
* band - Famous band name that created the tone
* duration - this is in seconds and may be fractional:
examples: 20.0, 34.5

Each attribute will have a corresponding getter(accessor)
function or setter(mutator) function. PLEASE PUT ONLY
FUNCTION PROTOTYPES IN YOUR CLASS; DO NOT ADD ANY FUNCTION
IMPLEMENTATION CODE. These would normally be put into a.cpp
file which you do not need to provide.

Also remember to add a default constructor as well as a constructor
that takes the attributes.

Solutions

Expert Solution

Thanks for the question.
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks!
===========================================================================

#ifndef FIZZJAZZ_H
#define FIZZJAZZ_H


#include<string>
using std::string;


class FizzJazz
{
   public:
       //default constructor
       FizzJazz();
       // parameterized constructor
       FizzJazz(string title, string band, double duration);
      
       // Each attribute will have a corresponding getter(accessor)
       string getTitle() const;
       string getBand() const;
       double getDuration() const;
      
       // function or setter(mutator) function
       void setTitle(string val);
       void setBand(string val);
       void setDuration(double val);
      
      
      
   private:
       string title;
       string band;
       double duration;
};

#endif

===================================================================

#include "FizzJazz.h"
#include<string>
using std::string;


//default constructor
FizzJazz::FizzJazz(): title(""), band(""), duration(0.0) {
  
}
// parameterized constructor
FizzJazz::FizzJazz(string title, string band, double duration)
: title(title), band(band), duration(duration) {
  
}

// Each attribute will have a corresponding getter(accessor)
string FizzJazz::getTitle() const {return title;}
string FizzJazz::getBand() const{return band;}
double FizzJazz::getDuration() const{return duration;}

// function or setter(mutator) function
void FizzJazz::setTitle(string val){title = val;}
void FizzJazz::setBand(string val){band = val;}
void FizzJazz::setDuration(double val){duration = val;}

===================================================================

#include <iostream>
#include "FizzJazz.h"
#include<string>

using namespace std;


int main() {
  
  
   FizzJazz fizz("Coca Cola","Pepsi",5.67);
  
   cout<<fizz.getTitle()<<endl;
   cout<<fizz.getBand()<<endl;
   cout<<fizz.getDuration()<<endl;
   return 0;
}

===================================================================


Related Solutions

Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
A header file contains a class template, and in that class there is a C++ string...
A header file contains a class template, and in that class there is a C++ string object. Group of answer choices(Pick one) 1)There should be a #include for the string library AND a using namespace std; in the header file. 2)There should be a #include for the string library. 3)There should be a #include for the string library AND a using namespace std; in the main program's CPP file, written before the H file's include.
Use the functions.h header file with your program (please write in C code): #ifndef FUNCTIONS_H #define...
Use the functions.h header file with your program (please write in C code): #ifndef FUNCTIONS_H #define FUNCTIONS_H typedef struct MyStruct { int value; char name[ 100 ]; } MyStruct; void sortArray( MyStruct*, int ); void printArray( MyStruct*, int ); #endif Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like...
......C++ PROGRAM.... Teacher would like us to split this program into a header file(filename.h), and a...
......C++ PROGRAM.... Teacher would like us to split this program into a header file(filename.h), and a .cpp file(filename.cpp). He gave us all the code, we just need to split it up. I do not quite understand how to do it. Please send output screenshot to show validation. #include <iostream> using namespace std; //public class class Account{ public: //instance variables double amount;    //creates account and sets amount with users account set-up value Account(double a){ amount = a; }    //adds...
What are the “guard statements” that we put in the .h file of a class definition?...
What are the “guard statements” that we put in the .h file of a class definition? Also tell what each of them do. ______________________________________________________________________________________________ What keywords are used to create, and release dynamic memory? ________________________________________________________________________________________ What is being made constant in the following member function of a Monkey class? Explain what each const is doing. const Zip& frappa( const Foo& thing ) const; _________________________________________________________________________________________ Thank you for the explain these problems.
**C++ program** Please provide a header file(bubble_sort.h) and a program file(bubble_sort.cpp). Also include notes to explain...
**C++ program** Please provide a header file(bubble_sort.h) and a program file(bubble_sort.cpp). Also include notes to explain code and output screenshots. Please use Bubble Sort code provided. Write a program for sorting a list of integers in ascending order using the bubble sort algorithm. Requirements Implement the following functions: Implement a function called readData int readData( int *arr) arr is a pointer for storing the integers. The function returns the number of integers. The function readData reads the list of integers...
Write a C++ program (The Account Class) Design a class named Account that contains (keep the...
Write a C++ program (The Account Class) Design a class named Account that contains (keep the data fields private): a) An int data field named id for the account. b) A double data field named balance for the account. c) A double data field named annualInterestRate that stores the current interest rate. d) A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. e) The accessor and mutator functions for id, balance, and annualInterestRate....
answer in c++ , Write the definition of the function NthOccurrence() whose header is int NthOccurrence(Array&...
answer in c++ , Write the definition of the function NthOccurrence() whose header is int NthOccurrence(Array& data,const T& value,int n) template It returns the index of the nth occurrence of value in data. If n is not positive, value appears less than n times in data or data is empty, it returns -1.
C++ Write a program that prompts for a file name and then reads the file to...
C++ Write a program that prompts for a file name and then reads the file to check for balanced curly braces, {; parentheses, (); and square brackets, []. Use a stack to store the most recent unmatched left symbol. The program should ignore any character that is not a parenthesis, curly brace, or square bracket. Note that proper nesting is required. For instance, [a(b]c) is invalid. Display the line number the error occurred on. These are a few of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT