Ybadoo - Soluções em Software Livre
Tutoriais
Programação Orientada a Objetos

Desenvolva uma classe chamada Equipamento com o atributo ligado (tipo boolean) e com os métodos liga e desliga. O método liga torna o atributo ligado verdadeiro e o método desliga torna o atributo ligado falso.

Desenvolva uma classe chamada EquipamentoSonoro que herda as características de Equipamento e que possui os atributos volume (tipo int) que varia de 0 a 10 e stereo (tipo boolean). A classe ainda deve possuir métodos para ler e alterar o volume, além dos métodos mono e stereo. O método mono torna o atributo stereo falso e o método stereo torna o atributo stereo verdadeiro. Ao ligar o EquipamentoSonoro através do método liga, seu volume é automaticamente ajustado para 5. Caso o volume seja configurado para um valor inválido, o sistema deverá lançar a exceção IllegalArgumentException.

 

Implementação na Linguagem de Programação Java Implementação na Linguagem de Programação C++
Diagrama de Classes na Linguagem de Programação Java Equipamento.java EquipamentoSonoro.java Application.java Saída da Implementação na Linguagem de Programação Java
Diagrama de Classes
Diagrama de Classes na Linguagem de Programação Java

Arquivo Equipamento.java

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * OpenJDK Version "1.8.0_121"                                           *
 * OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)               *
 *************************************************************************/

package com.ybadoo.tutoriais.poo.tutorial05.exercicio30;

/**
 * Classe responsavel pela representacao de um equipamento
 */
public class Equipamento
{
  /**
   * Status do equipamento
   */
  private boolean ligado;
  
  /**
   * Construtor para inicializar o equipamento
   */
  public Equipamento()
  {
    desliga();
  }
  
  /**
   * Retornar o status do equipamento
   * 
   * @return status do equipamento
   */
  public boolean getLigado()
  {
    return ligado;
  }
  
  /**
   * Desligar o equipamento
   */
  public void desliga()
  {
    ligado = false;
  }
  
  /**
   * Ligar o equipamento
   */
  public void liga()
  {
    ligado = true;
  }
}

Arquivo EquipamentoSonoro.java

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * OpenJDK Version "1.8.0_121"                                           *
 * OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)               *
 *************************************************************************/

package com.ybadoo.tutoriais.poo.tutorial05.exercicio30;

/**
 * Classe responsavel pela representacao de um equipamento sonoro
 */
public class EquipamentoSonoro extends Equipamento
{
  /**
   * Saida do equipamento sonoro
   */
  private boolean stereo;
  
  /**
   * Volume do equipamento sonoro
   */
  private int volume;
  
  /**
   * Construtor para inicializar o equipamento sonoro
   */
  public EquipamentoSonoro()
  {
    super();
  }
  
  /**
   * Retornar a saida do equipamento sonoro
   * 
   * @return saida do equipamento sonoro
   */
  public boolean getStereo()
  {
    return stereo;
  }
  
  /**
   * Configurar a saida do equipamento sonoro como mono
   */
  public void mono()
  {
    stereo = false;
  }
  
  /**
   * Configurar a saida do equipamento sonoro como stereo
   */
  public void stereo()
  {
    stereo = true;
  }

  /**
   * Retornar o volume do equipamento sonoro 
   * 
   * @return volume do equipamento sonoro
   */
  public int getVolume()
  {
    return volume;
  }

  /**
   * Configurar o volume do equipamento sonoro
   * 
   * @param volume volume do equipamento sonoro
   * @throws IllegalArgumentException volume fora do intervalo
   */
  public void setVolume(int volume) throws IllegalArgumentException
  {
    if((volume >= 0) && (volume <= 10))
    {
      this.volume = volume;
    }
    else
    {
      throw new IllegalArgumentException(Integer.toString(volume));
    }
  }

  /**
   * Ligar o equipamento sonoro
   */
  public void liga()
  {
    super.liga();
    
    setVolume(5);
  }
}

Arquivo Application.java

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * OpenJDK Version "1.8.0_121"                                           *
 * OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)               *
 *************************************************************************/

package com.ybadoo.tutoriais.poo.tutorial05.exercicio30;

/**
 * Classe responsavel pela execucao da classe EquipamentoSonoro
 */
public class Application
{
  /**
   * Construtor padrao
   */
  private Application()
  {

  }

  /**
   * Metodo principal da linguagem de programacao Java
   *
   * @param args argumentos da linha de comando (nao utilizado)
   */
  public static void main(String[] args)
  {
    EquipamentoSonoro equipamentoSonoro = new EquipamentoSonoro();

    System.out.print("Equipamento sonoro: ");
    System.out.println(equipamentoSonoro.getLigado() ? "ligado" : "desligado");

    System.out.println("... ligando o equipamento sonoro");

    equipamentoSonoro.liga();

    System.out.print("Equipamento sonoro: ");
    System.out.println(equipamentoSonoro.getLigado() ? "ligado" : "desligado");

    System.out.print("Stereo: ");
    System.out.println(equipamentoSonoro.getStereo() ? "ligado" : "desligado");

    System.out.println("... ligando o stereo");

    equipamentoSonoro.stereo();

    System.out.print("Stereo: ");
    System.out.println(equipamentoSonoro.getStereo() ? "ligado" : "desligado");

    System.out.print("Volume: ");
    System.out.println(equipamentoSonoro.getVolume());

    System.out.println("... desligando o equipamento sonoro");

    equipamentoSonoro.desliga();

    System.out.print("Equipamento sonoro: ");
    System.out.println(equipamentoSonoro.getLigado() ? "ligado" : "desligado");
  }
}

Saída da Implementação na Linguagem de Programação Java

Equipamento sonoro: desligado
... ligando o equipamento sonoro
Equipamento sonoro: ligado
Stereo: desligado
... ligando o stereo
Stereo: ligado
Volume: 5
... desligando o equipamento sonoro
Equipamento sonoro: desligado
Diagrama de Classes na Linguagem de Programação C++ Exception.hpp Exception.cpp IllegalArgumentException.hpp IllegalArgumentException.cpp Equipamento.hpp Equipamento.cpp EquipamentoSonoro.hpp EquipamentoSonoro.cpp Application.cpp makefile Saída da Implementação na Linguagem de Programação C++
Diagrama de Classes
Diagrama de Classes na Linguagem de Programação C++

Arquivo Exception.hpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#ifndef EXCEPTION_HPP
#define EXCEPTION_HPP

#include <string>

/**
 * Excecao padrao
 */
class Exception
{
  public:

  /**
   * Construtor padrao
   */
  Exception();

  /**
   * Construtor para inicializar a mensagem de erro
   *
   * @param message mensagem de erro
   */
  Exception(std::string message);

  /**
   * Retornar a mensagem de erro
   *
   * @return mensagem de erro
   */
  std::string getMessage();

  private:

  /**
   * Mensagem de erro
   */
  std::string message;
};

#endif

Arquivo Exception.cpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#include "Exception.hpp"

/**
 * Construtor padrao
 */
Exception::Exception()
{
  message = '\0';
}

/**
 * Construtor para inicializar a mensagem de erro
 *
 * @param message mensagem de erro
 */
Exception::Exception(std::string message)
{
  Exception::message = message;
}

/**
 * Retornar a mensagem de erro
 *
 * @return mensagem de erro
 */
std::string Exception::getMessage()
{
  return message;
}

Arquivo IllegalArgumentException.hpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#ifndef ILLEGALARGUMENTEXCEPTION_HPP
#define ILLEGALARGUMENTEXCEPTION_HPP

#include "Exception.hpp"

/**
 * Excecao lancada caso o metodo receba um parametro invalido
 */
class IllegalArgumentException : public Exception
{
  public:

  /**
   * Construtor padrao
   */
  IllegalArgumentException();

  /**
   * Construtor para inicializar a mensagem de erro
   *
   * @param message mensagem de erro
   */
  IllegalArgumentException(std::string message);
};

#endif

Arquivo IllegalArgumentException.cpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#include "IllegalArgumentException.hpp"

/**
 * Construtor padrao
 */
IllegalArgumentException::IllegalArgumentException()
                         :Exception()
{

}

/**
 * Construtor para inicializar a mensagem de erro
 *
 * @param message mensagem de erro
 */
IllegalArgumentException::IllegalArgumentException(std::string message)
                         :Exception(message)
{

}

Arquivo Equipamento.hpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#ifndef EQUIPAMENTO_HPP
#define EQUIPAMENTO_HPP

/**
 * Classe responsavel pela representacao de um equipamento
 */
class Equipamento
{
  public:

  /**
   * Construtor para inicializar o equipamento
   */
  Equipamento();

  /**
   * Retornar o status do equipamento
   *
   * @return status do equipamento
   */
  double getLigado();

  /**
   * Desligar o equipamento
   */
  void desliga();

  /**
   * Ligar o equipamento
   */
  void liga();

  private:

  /**
   * Status do equipamento
   */
  bool ligado;
};

#endif

Arquivo Equipamento.cpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#include "Equipamento.hpp"

/**
 * Construtor para inicializar o equipamento
 */
Equipamento::Equipamento()
{
  desliga();
}

/**
 * Retornar o status do equipamento
 *
 * @return status do equipamento
 */
double Equipamento::getLigado()
{
  return ligado;
}

/**
 * Desligar o equipamento
 */
void Equipamento::desliga()
{
  ligado = false;
}

/**
 * Ligar o equipamento
 */
void Equipamento::liga()
{
  ligado = true;
}

Arquivo EquipamentoSonoro.hpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#ifndef EQUIPAMENTOSONORO_HPP
#define EQUIPAMENTOSONORO_HPP

#include "Equipamento.hpp"
#include "IllegalArgumentException.hpp"

/**
 * Classe responsavel pela representacao de um equipamento sonoro
 */
class EquipamentoSonoro : public Equipamento
{
  public:

  /**
   * Construtor para inicializar o equipamento sonoro
   */
  EquipamentoSonoro();

  /**
   * Retornar a saida do equipamento sonoro
   * 
   * @return saida do equipamento sonoro
   */
  bool getStereo();
  
  /**
   * Configurar a saida do equipamento sonoro como mono
   */
  void mono();
  
  /**
   * Configurar a saida do equipamento sonoro como stereo
   */
  void stereo();

  /**
   * Retornar o volume do equipamento sonoro 
   * 
   * @return volume do equipamento sonoro
   */
  int getVolume();

  /**
   * Configurar o volume do equipamento sonoro
   * 
   * @param volume volume do equipamento sonoro
   * @throws IllegalArgumentException volume fora do intervalo
   */
  void setVolume(int volume) throw (IllegalArgumentException);

  /**
   * Ligar o equipamento
   */
  void liga();

  private:

  /**
   * Saida do equipamento sonoro
   */
  bool _stereo;
  
  /**
   * Volume do equipamento sonoro
   */
  int volume;
};

#endif

Arquivo EquipamentoSonoro.cpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#include <sstream>

#include "EquipamentoSonoro.hpp"

/**
 * Construtor padrao
 *
 * @throws IllegalArgumentException valor do lado do octogono invalido
 */
EquipamentoSonoro::EquipamentoSonoro()
                 : Equipamento() 
{

}

/**
 * Retornar a saida do equipamento sonoro
 * 
 * @return saida do equipamento sonoro
 */
bool EquipamentoSonoro::getStereo()
{
  return _stereo;
}
  
/**
 * Configurar a saida do equipamento sonoro como mono
 */
void EquipamentoSonoro::mono()
{
  _stereo = false;
}
  
/**
 * Configurar a saida do equipamento sonoro como stereo
 */
void EquipamentoSonoro::stereo()
{
  _stereo = true;
}

/**
 * Retornar o volume do equipamento sonoro 
 * 
 * @return volume do equipamento sonoro
 */
int EquipamentoSonoro::getVolume()
{
  return volume;
}

/**
 * Configurar o volume do equipamento sonoro
 * 
 * @param volume volume do equipamento sonoro
 * @throws IllegalArgumentException volume fora do intervalo
 */
void EquipamentoSonoro::setVolume(int volume)
  throw (IllegalArgumentException)
{
  if((volume >= 0) && (volume <= 10))
  {
    EquipamentoSonoro::volume = volume;
  }
  else
  {
    std::stringstream buffer;

    buffer << volume;

    throw IllegalArgumentException(buffer.str());
  }
}

/**
 * Ligar o equipamento
 */
void EquipamentoSonoro::liga()
{
  Equipamento::liga();

  setVolume(5);
}

Arquivo Application.cpp

/*************************************************************************
 * Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  *
 *                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  *
 *                                                                       *
 * Permission is granted to copy, distribute and/or modify this document *
 * under the terms of the GNU Free Documentation License, Version 1.3 or *
 * any later version published by the  Free Software Foundation; with no *
 * Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A *
 * A copy of the  license is included in  the section entitled "GNU Free *
 * Documentation License".                                               *
 *                                                                       *
 * Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             *
 * g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                           *
 *************************************************************************/

#include <iostream>

#include "EquipamentoSonoro.hpp"

using namespace std;

/**
 * Metodo principal da linguagem de programacao C++
 *
 * @param argc quantidade de argumentos na linha de comando (nao utilizado)
 * @param argv argumentos da linha de comando (nao utilizado)
 */
int main(int argc, char** argv)
{
  try
  {
    EquipamentoSonoro* equipamentoSonoro = new EquipamentoSonoro();

    cout << "Equipamento sonoro: "
         << (equipamentoSonoro->getLigado() ? "ligado" : "desligado")
         << endl;

    cout << "... ligando o equipamento sonoro" << endl;

    equipamentoSonoro->liga();

    cout << "Equipamento sonoro: "
         << (equipamentoSonoro->getLigado() ? "ligado" : "desligado")
         << endl;

    cout << "Stereo: "
         << (equipamentoSonoro->getStereo() ? "ligado" : "desligado")
         << endl;

    cout << "... ligando o stereo" << endl;

    equipamentoSonoro->stereo();

    cout << "Stereo: "
         << (equipamentoSonoro->getStereo() ? "ligado" : "desligado")
         << endl;

    cout << "Volume: "
         << equipamentoSonoro->getVolume() << endl;

    cout << "... desligando o equipamento sonoro" << endl;

    equipamentoSonoro->desliga();

    cout << "Equipamento sonoro: "
         << (equipamentoSonoro->getLigado() ? "ligado" : "desligado")
         << endl;

    delete equipamentoSonoro;
  }
  catch(IllegalArgumentException exception)
  {
    cerr << exception.getMessage() << endl;
  }
  catch(...)
  {
    cerr << "Exceção desconhecida" << endl;
  }

  return 0;
}

Arquivo makefile

##########################################################################
 # Copyright (C) 2009/2024 - Cristiano Lehrer (cristiano@ybadoo.com.br)  #
 #                  Ybadoo - Solucoes em Software Livre (ybadoo.com.br)  #
 #                                                                       #
 # Permission is granted to copy, distribute and/or modify this document #
 # under the terms of the GNU Free Documentation License, Version 1.3 or #
 # any later version published by the  Free Software Foundation; with no #
 # Invariant Sections,  no Front-Cover Texts, and no Back-Cover Texts. A #
 # A copy of the  license is included in  the section entitled "GNU Free #
 # Documentation License".                                               #
 #                                                                       #
 # Ubuntu 16.10 (GNU/Linux 4.8.0-39-generic)                             #
 # gcc/g++ (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005                       #
 ##########################################################################

g++ -o Exception.o -c Exception.cpp

g++ -o IllegalArgumentException.o -c IllegalArgumentException.cpp

g++ -o Equipamento.o -c Equipamento.cpp

g++ -o EquipamentoSonoro.o -c EquipamentoSonoro.cpp

g++ -o Application.o -c Application.cpp

g++ -o application Exception.o IllegalArgumentException.o Equipamento.o EquipamentoSonoro.o Application.o

Saída da Implementação na Linguagem de Programação C++

Equipamento sonoro: desligado
... ligando o equipamento sonoro
Equipamento sonoro: ligado
Stereo: desligado
... ligando o stereo
Stereo: ligado
Volume: 5
... desligando o equipamento sonoro
Equipamento sonoro: desligado