Question

In: Computer Science

Class as a ChapteredVideo. The constructor should take the following parameters: ID, length, num_chapters, chap_lengths, location,...

Class as a ChapteredVideo. The constructor should take the following parameters:

ID, length, num_chapters, chap_lengths, location, [extension]

The new parameter should be stored as their own instance variables. The ChapteredVideo object should behave as the Video. However, the method get_ID should now return a list which contains whatever the Video previously would return as its ID as the first element, followed by a list of chapter names. Each chapter name will be formed by the ID of the main video followed by ‘#’ and then the chapter number (starting at 1). For instance, a valid list could be ["123", "123#1", "123#2", "123#3"]. The ChapteredVideo class should also have a new accessor method, get_num_chapters.

Implement ChapteredVideo class as specified above.

Solutions

Expert Solution

#include<bits/stdc++.h>
using namespace std;

class ChapteredVideo
{
    int ID, length, num_chapters, chap_lengths;
    string location;
    string extension;
    vector <string> chapName;

public:
    ChapteredVideo(int ID, int length, int num_chapters, int chap_lengths, string location, string extension)
    {
        this->ID = ID;
        this->length = length;
        this->num_chapters = num_chapters;
        this->chap_lengths = chap_lengths;
        this->location = location;
        this->extension = extension;
    }

    vector<string> get_ID()
    {
        vector<string> R;
        R.push_back(to_string(this->ID));
    for (int i = 0; i < this->chapName.size();i++)
    {
            R.push_back(this->chapName[i]);
    }
            return R;
    }

    int get_num_chapters(){
        return this->num_chapters;
    }
    void addChapName(int i){
        string c = to_string(this->ID) + "#" + to_string(i);
       
        this->chapName.push_back(c);
    }
};

int main()
{
    ChapteredVideo c1(123, 23, 12, 40, "C", "mp4");

    for (int i = 1; i < 10;i++)
        c1.addChapName(i);
    vector<string> I = c1.get_ID();
    for (auto itr : I)
    {
        cout << itr <<" ";
    }
    return 0;
}

Related Solutions

Write anoyher overloaded constructor for this class. Thr constructor should accept an argumrny for each field....
Write anoyher overloaded constructor for this class. Thr constructor should accept an argumrny for each field. C++ I need help thanks.
In Angel, you will find a class called Employee. This class should include a constructor which...
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will...
In Angel, you will find a class called Employee. This class should include a constructor which...
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will...
In C++ Write a class named TestScores. The class constructor should accept an array of test...
In C++ Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a member function that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an exception. Demonstrate the class in program.
Write a class named TestScores. The class constructor should accept an array of test scores as...
Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException. Demonstrate the class in a program. Use TestScoresDemo.java to test your code public class TestScoresDemo { public static void main(String[] args) { // An array with test scores. //...
In Angel, you will find a class called Employee. This class should include a constructor which...
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will...
you will find a class called Employee. This class should include a constructor that sets name...
you will find a class called Employee. This class should include a constructor that sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will create a...
Q3) Design a class for saving data of employee, the class should have multiple constructors (constructor...
Q3) Design a class for saving data of employee, the class should have multiple constructors (constructor overloading) for initializing objects with different parameters. The employee class should have different functions for saving and updating bio-data, educational background, and current status like experience, Salary, position & travel history. The employee class should have a function which asks user what do he likes to see about employee (.i.e., Bio-data, current status....) and only show the respective data. Create two objects of interns...
This is for Javascript programming language: A. Class and Constructor Creation Book Class Create a constructor...
This is for Javascript programming language: A. Class and Constructor Creation Book Class Create a constructor function or ES6 class for a Book object. The Book object should store the following data in attributes: title and author. Library Class Create a constructor function or ES6 class for a Library object that will be used with the Book class. The Library object should be able to internally keep an array of Book objects. B. Methods to add Library Class The class...
- Create a java class named SaveFile in which write the following: Constructor: The class's constructor...
- Create a java class named SaveFile in which write the following: Constructor: The class's constructor should take the name of a file as an argument A method save (String line): This method should open the file defined by the constructor, save the string value of line at the end of the file, and then close the file. - In the same package create a new Java class and it DisplayFile in which write the following: Constructor: The class's constructor...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT