Graderpractice for programmers

Back to 254275 OOP - Labs 6-10 Review

2. Add the toString method

Problem

Add a new method to the Album named toString that returns title - artist.

Test code:

class Task2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String title = sc.nextLine();
        String artist = sc.nextLine();
        int songs = Integer.parseInt(sc.nextLine());

        Album album1 = new Album(title, artist, songs);
        System.out.println(album1.toString());
    }
}

Examples

Input

Nevermind
Nirvana
12

Output

Nevermind - Nirvana

Submit your solution

java