Graderpractice for programmers

Back to 254275 OOP - Labs 6-10 Review

4. Create a Soundtrack class

Problem

A soundtrack is an album with music from a movie. Write a class named Soundtrack that is a subclass of Album with an extra field for "movie".

Test code:

class Task4 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String movie = sc.nextLine();
        int songs = Integer.parseInt(sc.nextLine());
        
        Album st1 = new Soundtrack(movie + " Soundtrack", "Various Artists", songs, movie);
        System.out.println(st1.toString());
    }
}

Examples

Input

La La Land
15

Output

La La Land Soundtrack - Various Artists

Submit your solution

java