钢琴java代码csdn 钢琴曲代码

给段最简单的java代码 让我新手看一下

最简单的java代码肯定就是这个了,如下:

成都创新互联专注于企业成都营销网站建设、网站重做改版、邹城网站定制设计、自适应品牌网站建设、html5商城网站开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为邹城等各大城市提供网站开发制作服务。

public class MyFirstApp

{

public static void main(String[] args)

{

System.out.print("Hello world");

}

}

“hello world”就是应该是所有学java的新手看的第一个代码了。如果是零基础的新手朋友们可以来我们的java实验班试听,有免费的试听课程帮助学习java必备基础知识,有助教老师为零基础的人提供个人学习方案,学习完成后有考评团进行专业测试,帮助测评学员是否适合继续学习java,15天内免费帮助来报名体验实验班的新手快速入门java,更好的学习java!

教我写下小代码吧 java

interface Instrument{

void play();

}

class Piano implements Instrument{

public void play() {

System.out.println("play Piano");

}

}

class Violin implements Instrument{

public void play() {

System.out.println("play Violin");

}

}

public class InstrumentTest{

public static void main(String[] args) {

Instrument i1 = new Piano();

Instrument i2 = new Violin();

i1.play();

i2.play();

}

}

java类的多态编程。 (1)乐器(Instrument)分为:钢琴(Piano)、小提琴(Vio

public class Instrument {   

public void play(){

System.out.println("演奏乐器......");

}

}

public class Piano extends Instrument{

public void play(){

System.out.println("弹奏钢琴......");

}

}

public class Violin extends Instrument{

public void play(){

System.out.println("演奏小提琴......");

}

}

public class TestPlay {

public static void main(String[] args) {

Instrument pr = new Instrument();

pr.play();

Instrument p = new Piano();

p.play();

Instrument v = new Violin();

v.play();

}

}

java三种乐器弹奏方法不同……源代码

 /**

* 歌曲类

*/

public class Music {

public Music() {

super();

}

public Music(String song) {

super();

System.out.println("《"+song+"》");

System.out.println(".....多来米发所拉稀....");

}

}

/**

* 乐器接口,凡实现该接口的都游演奏的功能

*/

public interface Instrument {

public Music musical(String song);

}

/**

* 管弦类乐器

*/

public class Orchestral implements Instrument {

public Music musical(String song) {

System.out.println("下面用管弦类乐器演奏 "+song);

return new Music(song);

}

}

/**

* 弹奏类乐器

*/

public class Spiccato implements Instrument {

public Music musical(String song) {

System.out.println("下面用弹奏类乐器弹奏 "+song);

return new Music(song);

}

}

/**

* 其他类型乐器

*/

public class Other implements Instrument {

String instrument;

public Other() {

super();

}

public Other(String instrument) {

this.instrument = instrument;

}

public Music musical(String song) {

System.out.println("用 "+instrument+" 演奏的 "+song);

return new Music(song);

}

public static void main(String[] args) {

Other other = new Other("古筝");

other.musical("高山流水");

}

}

/**

* 笛子

*/

public class Fife extends Orchestral {

public Fife(String song) {

super.musical(song);

System.out.println("这是用横笛吹奏的 "+song);

}

}

/**

* 萨克斯

*/

public class Sax extends Orchestral {

public Sax(String song) {

super.musical(song);

System.out.println("这是用萨克斯演奏的 "+song);

}

}

/**

* 吉他

*/

public class Guitar extends Spiccato {

public Guitar(String song) {

super.musical(song);

System.out.println("这是吉他弹奏的");

}

}

/**

* 钢琴

*/

public class Piano extends Spiccato {

public Piano() {

super();

}

public Piano(String song) {

super.musical(song);

System.out.println("这是在用钢琴弹奏 "+song);

}

}


网站标题:钢琴java代码csdn 钢琴曲代码
本文URL:http://pwwzsj.com/article/dohegcg.html