Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public interface Instrument {
- public void play();
- public String KEY="До мажор";
- }
- public static class Guitar implements Instrument {
- int StringsQuantity = 6;
- public void play() {
- System.out.println("Играет гитара, у неё " +StringsQuantity+ " струн");
- }
- }
- public static class Drum implements Instrument {
- String Size = "большого";
- public void play() {
- System.out.println("Играет барабан, он " +Size+ " размера");
- }
- }
- public static class Pipe implements Instrument {
- int Diameter = 40;
- public void play() {
- System.out.println("Играет труба диаметром " +Diameter);
- }
- }
- public static void main(String[] args) {
- Guitar Acoustic = new Guitar();
- Drum Tambourine = new Drum();
- Pipe Tube = new Pipe();
- Instrument[] Band = new Instrument[] {Acoustic, Tambourine, Tube};
- for (int i=0; i<3; i++) {
- Band[i].play();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement