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

Create a class called Cuboid in a file called cuboid.py. The constructor should take parameters that...
Create a class called Cuboid in a file called cuboid.py. The constructor should take parameters that sets a private variable for each side of the cuboid. Overload the following operators: +, -, <, >, ==, len(), and str(). Return a cuboid with the appropriate volume for the arithmetic operators. Use the volume of the cuboid to determine the output of the overloaded comparison operators. Use the surface area of the cuboid to calculate the result of len(). For str() return...
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...
Create Course object class (Course.java) Course object should be the following attributes: Course id:12345 Instructor id:...
Create Course object class (Course.java) Course object should be the following attributes: Course id:12345 Instructor id: 9876 Room id: 101 I have everything written out but it won't compile, any help? public class Course {    private int course id;    private int instructor id;    private int room id;    Course()    {        setCourseID (13233);        setInsID    (001);        setRoomID    (101);    }    Course(int courseID, int instructorID, int roomID)    {   ...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT