java编程题,基础

2022-04-23 综合 57阅读
package com.sunpx.test;

public class Song {

    protected String name;
    protected String composer;
    protected int year;


    public Song(String name, String composer, int year) {
        this.name = name;
        this.composer = composer;
        this.year = year;
    }
    public Song(String name){
        this.name = name;
    }


    @Override
    public String toString() {
        return "Song{" +
                "name='" + name + '\'' +
                ", composer='" + composer + '\'' +
                ", year=" + year +
                '}';
    }

    public String toString(int year) {
        String yearN = String.valueOf(year);
        return "Song{" +
                "name='" + name + '\'' +
                ", composer='" + composer + '\'' +
                ", year=" + yearN +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getComposer() {
        return composer;
    }

    public void setComposer(String composer) {
        this.composer = composer;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com