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...
answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
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...
In Visual Studios 2017, using c++, Create a class (Scores) that stores test scores (integers) in...
In Visual Studios 2017, using c++, Create a class (Scores) that stores test scores (integers) in an array (assume a maximum of 100 scores). The class should have a constructor that allows the client to specify the initial value of the scores (the same initial value applies to all of them) and another default constructor that initializes them to 0. The class should have functions as follows: 1. A member function that adds a score to the array.  The client must...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT