Question

In: Computer Science

Program is to be written in C++ using Visual studios Community You are to design a...

Program is to be written in C++ using Visual studios Community

You are to design a system to keep track of either a CD or DVD/Blu-ray collection. The program will only work exclusively with either CDs or DVDs/Blu-rays since some of the data is different. Which item your program will work with will be up to you. Each CD/DVD/Blu-ray in the collection will be represented as a class, so there will be one class that is the CD/DVD/Blu-ray. The CD class will be limited to five (5) songs, and the class will need to keep an array of five (5) strings for the song titles. It should also maintain the length of each song and the total length of the CD, as well as the artist name. The DVD/Blu-ray class will have a data member for the title of the movie, length of the movie, the year of the movie, and for the names of two of the main actors in the movie. There will be a class that maintains the list of CD/DVDs/Blu-rays. This list can be limited to just 5 CD/DVD/Blu-rays and provide a method to add a CD/DVD/Blu-ray, to remove a CD/DVD/Blu-ray, and to update a CD/DVD/Blu-ray.

The program should provide a menu for the user to be able to add, delete, update and display the information in a CD/DVD/Blu-ray. Include a comment block at the top of the code file of what the program does.

Solutions

Expert Solution

1. The solution contains 3 classes Cd , Dvd and CollectionCD_DVD.

2. Implementation can be seen inside the code.

3. Methods like display can be fully implemented using the below code as reference.

Code :

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//class CD
class Cd{
    public : 
    string songs[5];
    int songLen[5];
    int cdLen;
    string artistName;
    public : Cd (){
    }
    public : Cd(string song[], int songLe[],int cdL, string artistn)
    {
      for(int i = 0; i < 5; ++i)
        {songLen[i] = songLe[i];
        songs[i] = song[i];}
        cdLen = cdL;
        artistName = artistn;
    }
};
// class dvd
class Dvd{
    public :
    string title;
    int length;
    int year;
    string actor1;
    string actor2;
    public : Dvd(){

    }
    public : Dvd(string mtitle, int mlength,int myear, string mactor1,string mactor2)
    {
      title = mtitle;
      length = mlength;
      year = myear;
      actor2 = mactor2;
      actor1 = mactor1;

    }
};
//class containing the list of cd/dvd
class CollectionCD_DVD{
    int noCd=0;
    int noDvd=0;
    Cd cdList[5];
    Dvd dvdList[5];
    public : CollectionCD_DVD()
    {}
    
    void addCd(Cd cd)
    {
        cdList[noCd++]=cd;
        cout<<"added cd\n";
    }
     void addDvd(Dvd dvd)
    {
       dvdList[noDvd++]=dvd;
        cout<<"added dvd\n";
    }  
    void updateCD(int index, Cd cd)
    {
      cdList[index]=cd;
      cout<<"updated cd\n";
    }
    void updateDvd(int index, Dvd dvd)
    {
      dvdList[index]=dvd;
      cout<<"updated dvd\n";
    }
    void deleteCd()
    {
    noCd--;
     //last element of the cd gets deleted
    }
     void deleteDvd()
    {
    noDvd--;
     //last element of the dvd gets deleted
    }

    void display()
    {
       for(int i=0;i<5;i++)
       cout<<cdList[i].artistName<<endl;

       //you can display other fields similarly
    }
};
int main()
{
  CollectionCD_DVD obj = CollectionCD_DVD();

  string s[5]= {"a","b","c","d","e"};
  int l[5] = {1,2,3,4,5};
  Cd cd = Cd(s,l,15,"dummyartist");
  Dvd dvd = Dvd("avb",12,12,"abc","abc");
  //adding item to list cd
  obj.addCd(cd);
  obj.addCd(cd);
  obj.addCd(cd);
  obj.addCd(cd);
  obj.addCd(cd);
  //adding item to the list dvd
  obj.addDvd(dvd);
  obj.addDvd(dvd);
  obj.addDvd(dvd);
  obj.addDvd(dvd);
  obj.addDvd(dvd);
 //methods of the class
  obj.display();
  obj.deleteDvd();
  obj.deleteCd();
  obj.updateCD(2, cd);


        return 0;
}

Output :


Related Solutions

Must be written in C++ in Visual studios community In this lab, you will modify the...
Must be written in C++ in Visual studios community In this lab, you will modify the Student class you created in a previous lab. You will modify one new data member which will be a static integer data member. Call that data member count. You also add a static method to the Student class that will display the value of count with a message indicating what the value represents, meaning I do not want to just see a value printed...
Code should be written in C++ using Visual Studios Community This requires several classes to interact...
Code should be written in C++ using Visual Studios Community This requires several classes to interact with each other. Two class aggregations are formed. The program will simulate a police officer giving out tickets for parked cars whose meters have expired. You must include both a header file and an implementation file for each class. Car class (include Car.h and Car.cpp) Contains the information about a car. Contains data members for the following String make String model String color String...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that serves as a healthcare billing management system. This application is a multiform project (Chapter 9) with three buttons. The "All Accounts" button allows the user to see all the account information for each patient which is stored in an array of class type objects (Chapter 9, section 9.4).The "Charge Service" button calls the Debit method which charges the selected service to the patient's account...
DEVELOP IN VISUAL STUDIOS C++ PLEASE 1. Develop a main program that does the following a)...
DEVELOP IN VISUAL STUDIOS C++ PLEASE 1. Develop a main program that does the following a) Create six nodes of integers such as n0, n1, n2, n3, n4, n5 (n0 is the head) b) Assign data to each nodes such as n1->data = 2; n2->data = 5, n3->data = 3, n4->data = 10, n5->data = 1. c) Make n0 ->next to point to n1, and n0->prev to point to NULL 2.) Print out the content of list you have created...
I need this code in C++ form using visual studios please: Create a class that simulates...
I need this code in C++ form using visual studios please: Create a class that simulates an alarm clock. In this class you should: •       Store time in hours, minutes, and seconds. Note if time is AM or PM. (Hint: You should have separate private members for the alarm and the clock. Do not forget to have a character variable representing AM or PM.) •       Initialize the clock to a specified time. •       Allow the clock to increment to the...
ASSEMBLY X86, using VISUAL STUDIOS 2019 Please follow ALL directions! Write a program that calculates and...
ASSEMBLY X86, using VISUAL STUDIOS 2019 Please follow ALL directions! Write a program that calculates and printout the first 6 Fibonacci numbers.   Fibonacci sequence is described by the following formula: Fib(0) = 0, Fib(1) = 1, Fib(2) = Fib(0)+ Fib(1), Fib(n) = Fib(n-1) + Fib(n-2). (sequence 0 1 1 2 3 5 8 13 21 34 ...) Have your program print out "The first six numbers in the Fibonacci Sequence are". Then the numbers should be neatly printed out, with...
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
Your task is to create a book ordering form using VISUAL STUDIOS, with the code and...
Your task is to create a book ordering form using VISUAL STUDIOS, with the code and screenshots 1. Boxes for first name, last name, address. 2. Radio buttons to select: hard cover, soft cover, ebook. 3. Drop down list to select the book (make up three or four book names). 4. Radio buttons to select credit card (at least Visa, Master Card, American Express). 5. Box to enter credit card numbers. 6. The credit card box MUST verify that numbers...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT