JAVA:编写一个音乐类,属性包括音乐名称音乐类型,方法为显示音乐信息,并编写测试类

高手们有没有人讲详细点的,我想问一下,JAVA:编写一个音乐类,属性包括音乐名称音乐类型,方法为显示音乐信息,并编写测试类
最新回答
鸢尾*

2024-05-02 19:17:40

public class TestValid
{
public static void main(String[] args)
{
Music music = new Music("abc", "bcd");
music.show();
}
}

class Music
{
private String musicName;
private String musicType;
public Music(String musicName, String musicType)
{
super();
this.musicName = musicName;
this.musicType = musicType;
}
public String getMusicName()
{
return musicName;
}
public void setMusicName(String musicName)
{
this.musicName = musicName;
}
public String getMusicType()
{
return musicType;
}
public void setMusicType(String musicType)
{
this.musicType = musicType;
}
public void show()
{
System.out.println("Music [musicName=" + musicName + ", musicType=" + musicType
+ "]");;
}

}