Desenvolva uma classe chamada Transport
para representar um veículo de transporte. A classe possui cinco atributos, denominados:
name
: nome do veículo de transporte, do tipo String
;height
: altura do veículo de transporte em metros (m), do tipo double
;length
: comprimento do veículo de transporte em metros (m), do tipo double
;payload
: capacidade de carga do veículo de transporte em toneladas (t), do tipo int
;speed
: velocidade do veículo de transporte em quilômetros por hora (km/h), do tipo int
.Estenda a classe Transport
para implementar uma classe chamada AirTransport
para representar um veículo de transporte aéreo. A classe possui dois atributos, denominados:
range
: autonomia de voo do veículo de transporte aéreo em quilômetros (km), do tipo int
;wingspan
: envergadura da asa do veículo de transporte aéreo em metros (m), do tipo double
.Estenda a classe Transport
para implementar uma classe chamada LandTransport
para representar um veículo de transporte terrestre. A classe possui dois atributos, denominados:
engine
: motor do veículo de transporte terrestre, do tipo String
;wheels
: rodas do veículo de transporte terrestre, do tipo String
.Estenda a classe Transport
para implementar uma classe chamada WaterTransport
para representar um veículo de transporte marítimo. A classe possui dois atributos, denominados:
beam
: boca do veículo de transporte marítimo em metros (m), do tipo int
;draught
: calado do veículo de transporte marítimo em metros (m), do tipo int
.Desenvolva uma classe chamada Catalog
para representar um catálogo de veículos de transporte, implementando os métodos para inserção e apresentação dos veículos de transporte cadastrados.
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
package com.ybadoo.tutoriais.poo;
/**
* Classe responsavel pela representacao de um veiculo de transporte
*/
public abstract class Transport
{
/**
* Nome do veiculo de transporte
*/
private String name;
/**
* Altura do veiculo de transporte em metros (m)
*/
private double height;
/**
* Comprimento do veiculo de transporte em metros (m)
*/
private double length;
/**
* Capacidade de carga do veiculo de transporte em toneladas (t)
*/
private int payload;
/**
* Velocidade do veiculo de transporte em quilometros por hora (km/h)
*/
private int speed;
/**
* Construtor padrao
*/
public Transport()
{
name = null;
height = 0.0;
length = 0.0;
payload = 0;
speed = 0;
}
/**
* Retornar o nome do veiculo de transporte
*
* @return nome do veiculo de transporte
*/
public String getName()
{
return name;
}
/**
* Configurar o nome do veiculo de transporte
*
* @param name nome do veiculo de transporte
*/
public void setName(String name)
{
this.name = name;
}
/**
* Retornar a altura do veiculo de transporte em metros (m)
*
* @return altura do veiculo de transporte em metros (m)
*/
public double getHeight()
{
return height;
}
/**
* Configurar a altura do veiculo de transporte em metros (m)
*
* @param height altura do veiculo de transporte em metros (m)
*/
public void setHeight(double height)
{
if(height > 0.0)
{
this.height = height;
}
}
/**
* Retornar o comprimento do veiculo de transporte em metros (m)
*
* @return comprimento do veiculo de transporte em metros (m)
*/
public double getLength()
{
return length;
}
/**
* Configurar o comprimento do veiculo de transporte em metros (m)
*
* @param length comprimento do veiculo de transporte em metros (m)
*/
public void setLength(double length)
{
if(length > 0.0)
{
this.length = length;
}
}
/**
* Retornar a capacidade de carga do veiculo de transporte em
* toneladas (t)
*
* @return capacidade de carga do veiculo de transporte em
* toneladas (t)
*/
public int getPayload()
{
return payload;
}
/**
* Configurar a capacidade de carga do veiculo de transporte em
* toneladas (t)
*
* @param payload capacidade de carga do veiculo de transporte em
* toneladas (t)
*/
public void setPayload(int payload)
{
if(payload > 0)
{
this.payload = payload;
}
}
/**
* Retornar a velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*
* @return velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*/
public int getSpeed()
{
return speed;
}
/**
* Configurar a velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*
* @param speed velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*/
public void setSpeed(int speed)
{
if(speed > 0)
{
this.speed = speed;
}
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuilder buffer = new StringBuilder();
buffer.append(getName())
.append("\n");
buffer.append("Altura: ")
.append(getHeight())
.append(" m\n");
buffer.append("Comprimento: ")
.append(getLength())
.append(" m\n");
buffer.append("Capacidade de carga: ")
.append(getPayload())
.append(" t\n");
buffer.append("Velocidade: ")
.append(getSpeed())
.append(" km/h");
return buffer.toString();
}
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
package com.ybadoo.tutoriais.poo;
/**
* Classe responsavel pela representacao de um veiculo de transporte aereo
*/
public class AirTransport extends Transport
{
/**
* Autonomia de voo do veiculo de transporte aereo em quilometros (km)
*/
private int range;
/**
* Envergadura da asa do veiculo de transporte aereo em metros (m)
*/
private double wingspan;
/**
* Construtor padrao
*/
public AirTransport()
{
super();
range = 0;
wingspan = 0.0;
}
/**
* Retornar a autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*
* @return autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*/
public int getRange()
{
return range;
}
/**
* Configurar a autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*
* @param range autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*/
public void setRange(int range)
{
if(range > 0)
{
this.range = range;
}
}
/**
* Retornar a envergadura da asa do veiculo de transporte aereo em
* metros (m)
*
* @return envergadura da asa do veiculo de transporte aereo em
* metros (m)
*/
public double getWingspan()
{
return wingspan;
}
/**
* Configurar a envergadura da asa do veiculo de transporte aereo em
* metros (m)
*
* @param wingspan envergadura da asa do veiculo de transporte aereo em
* metros (m)
*/
public void setWingspan(double wingspan)
{
if(wingspan > 0.0)
{
this.wingspan = wingspan;
}
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuilder buffer = new StringBuilder();
buffer.append("Veículo de transporte aéreo: ")
.append(super.toString())
.append("\n");
buffer.append("Autonomia de voo: ")
.append(getRange())
.append(" km\n");
buffer.append("Envergadura da asa: ")
.append(getWingspan())
.append(" m\n");
return buffer.toString();
}
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
package com.ybadoo.tutoriais.poo;
/**
* Classe responsavel pela representacao de um veiculo de transporte
* terrestre
*/
public class LandTransport extends Transport
{
/**
* Motor do veiculo de transporte terrestre
*/
private String engine;
/**
* Rodas do veiculo de transporte terrestre
*/
private String wheels;
/**
* Construtor padrao
*/
public LandTransport()
{
super();
engine = null;
wheels = null;
}
/**
* Retornar o motor veiculo de transporte terrestre
*
* @return motor veiculo de transporte terrestre
*/
public String getEngine()
{
return engine;
}
/**
* Configurar o motor veiculo de transporte terrestre
*
* @param engine motor veiculo de transporte terrestre
*/
public void setEngine(String engine)
{
this.engine = engine;
}
/**
* Retornar as rodas do veiculo de transporte terrestre
*
* @return rodas do veiculo de transporte terrestre
*/
public String getWheels()
{
return wheels;
}
/**
* Configurar as rodas do veiculo de transporte terrestre
*
* @param wheels rodas do veiculo de transporte terrestre
*/
public void setWheels(String wheels)
{
this.wheels = wheels;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuilder buffer = new StringBuilder();
buffer.append("Veículo de transporte terrestre: ")
.append(super.toString())
.append("\n");
buffer.append("Motor: ")
.append(getEngine())
.append("\n");
buffer.append("Rodas: ")
.append(getWheels())
.append("\n");
return buffer.toString();
}
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
package com.ybadoo.tutoriais.poo;
/**
* Classe responsavel pela representacao de um veiculo de transporte
* maritimo
*/
public class WaterTransport extends Transport
{
/**
* Boca do veiculo de transporte maritimo em metros (m)
*/
private int beam;
/**
* Calado do veiculo de transporte maritimo em metros (m)
*/
private int draught;
/**
* Construtor padrao
*/
public WaterTransport()
{
super();
beam = 0;
draught = 0;
}
/**
* Retornar a boca do veiculo de transporte maritimo em metros (m)
*
* @return boca do veiculo de transporte maritimo em metros (m)
*/
public int getBeam()
{
return beam;
}
/**
* Configurar a boca do veiculo de transporte maritimo em metros (m)
*
* @param beam boca do veiculo de transporte maritimo em metros (m)
*/
public void setBeam(int beam)
{
if(beam > 0)
{
this.beam = beam;
}
}
/**
* Retornar o calado do veiculo de transporte maritimo em metros (m)
*
* @return calado do veiculo de transporte maritimo em metros (m)
*/
public int getDraught()
{
return draught;
}
/**
* Configurar o calado do veiculo de transporte maritimo em metros (m)
*
* @param draught calado do veiculo de transporte maritimo em metros (m)
*/
public void setDraught(int draught)
{
if(draught > 0)
{
this.draught = draught;
}
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuilder buffer = new StringBuilder();
buffer.append("Veículo de transporte marítimo: ")
.append(super.toString())
.append("\n");
buffer.append("Boca: ")
.append(getBeam())
.append(" m\n");
buffer.append("Calado: ")
.append(getDraught())
.append(" m\n");
return buffer.toString();
}
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
package com.ybadoo.tutoriais.poo;
import java.util.ArrayList;
import java.util.List;
/**
* Classe responsavel pela representacao de um catalogo de veiculos de
* transporte
*/
public class Catalog
{
/**
* Veiculos de transporte
*/
private List<Transport> vehicles;
/**
* Construtor padrao
*/
public Catalog()
{
vehicles = new ArrayList<Transport>();
}
/**
* Adicionar um veiculos de transporte ao catalogo
*
* @param transport veiculo de transporte a ser adicionado ao catalogo
*/
public void add(Transport transport)
{
vehicles.add(transport);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuilder buffer = new StringBuilder();
for(Transport transport: vehicles)
{
buffer.append(transport).append("\n");
}
return buffer.toString();
}
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
package com.ybadoo.tutoriais.poo;
/**
* Classe responsavel pela execucao da classe Transport
*/
public class Application
{
/**
* Metodo principal da linguagem de programacao Java
*
* @param args argumentos da linha de comando (nao utilizado)
*/
public static void main(String[] args)
{
Catalog catalog = new Catalog();
AirTransport antonov = new AirTransport();
antonov.setName("Antonov An-225");
antonov.setHeight(18.1);
antonov.setLength(84.0);
antonov.setPayload(275);
antonov.setSpeed(865);
antonov.setRange(4500);
antonov.setWingspan(88.4);
catalog.add(antonov);
LandTransport belaz = new LandTransport();
belaz.setName("BelAZ 75710");
belaz.setHeight(8.16);
belaz.setLength(20.6);
belaz.setPayload(450);
belaz.setSpeed(64);
belaz.setEngine("MTU DD 16V4000");
belaz.setWheels("59/80R63");
catalog.add(belaz);
WaterTransport vale = new WaterTransport();
vale.setName("Vale Brasil");
vale.setHeight(56);
vale.setLength(362);
vale.setPayload(400000);
vale.setSpeed(28);
vale.setBeam(65);
vale.setDraught(23);
catalog.add(vale);
System.out.println(catalog);
}
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <string>
using namespace std;
#ifndef TRANSPORT_H
#define TRANSPORT_H
/**
* Classe responsavel pela representacao de um veiculo de transporte
*/
class Transport
{
private:
/**
* Nome do veiculo de transporte
*/
string* name;
/**
* Altura do veiculo de transporte em metros (m)
*/
double height;
/**
* Comprimento do veiculo de transporte em metros (m)
*/
double length;
/**
* Capacidade de carga do veiculo de transporte em toneladas (t)
*/
int payload;
/**
* Velocidade do veiculo de transporte em quilometros por hora (km/h)
*/
int speed;
protected:
/**
* Construtor padrao
*/
Transport();
public:
/**
* Destrutor padrao
*/
~Transport();
/**
* Retornar o nome do veiculo de transporte
*
* @return nome do veiculo de transporte
*/
string* getName();
/**
* Configurar o nome do veiculo de transporte
*
* @param name nome do veiculo de transporte
*/
void setName(string* name);
/**
* Retornar a altura do veiculo de transporte em metros (m)
*
* @return altura do veiculo de transporte em metros (m)
*/
double getHeight();
/**
* Configurar a altura do veiculo de transporte em metros (m)
*
* @param height altura do veiculo de transporte em metros (m)
*/
void setHeight(double height);
/**
* Retornar o comprimento do veiculo de transporte em metros (m)
*
* @return comprimento do veiculo de transporte em metros (m)
*/
double getLength();
/**
* Configurar o comprimento do veiculo de transporte em metros (m)
*
* @param length comprimento do veiculo de transporte em metros (m)
*/
void setLength(double length);
/**
* Retornar a capacidade de carga do veiculo de transporte em
* toneladas (t)
*
* @return capacidade de carga do veiculo de transporte em
* toneladas (t)
*/
int getPayload();
/**
* Configurar a capacidade de carga do veiculo de transporte em
* toneladas (t)
*
* @param payload capacidade de carga do veiculo de transporte em
* toneladas (t)
*/
void setPayload(int payload);
/**
* Retornar a velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*
* @return velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*/
int getSpeed();
/**
* Configurar a velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*
* @param speed velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*/
void setSpeed(int speed);
/*
* Retornar os atributos do veiculo de transporte
*
* @return atributos do veiculo de transporte
*/
virtual string* toString();
};
#endif
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <cstdlib>
#include <sstream>
#include "Transport.h"
using namespace std;
/**
* Construtor padrao
*/
Transport::Transport()
{
name = NULL;
height = 0.0;
length = 0.0;
payload = 0;
speed = 0;
}
/**
* Destrutor padrao
*/
Transport::~Transport()
{
if(name != NULL)
{
free(name);
}
}
/**
* Retornar o nome do veiculo de transporte
*
* @return nome do veiculo de transporte
*/
string* Transport::getName()
{
return name;
}
/**
* Configurar o nome do veiculo de transporte
*
* @param name nome do veiculo de transporte
*/
void Transport::setName(string* name)
{
Transport::name = name;
}
/**
* Retornar a altura do veiculo de transporte em metros (m)
*
* @return altura do veiculo de transporte em metros (m)
*/
double Transport::getHeight()
{
return height;
}
/**
* Configurar a altura do veiculo de transporte em metros (m)
*
* @param height altura do veiculo de transporte em metros (m)
*/
void Transport::setHeight(double height)
{
if(height > 0.0)
{
Transport::height = height;
}
}
/**
* Retornar o comprimento do veiculo de transporte em metros (m)
*
* @return comprimento do veiculo de transporte em metros (m)
*/
double Transport::getLength()
{
return length;
}
/**
* Configurar o comprimento do veiculo de transporte em metros (m)
*
* @param length comprimento do veiculo de transporte em metros (m)
*/
void Transport::setLength(double length)
{
if(length > 0.0)
{
Transport::length = length;
}
}
/**
* Retornar a capacidade de carga do veiculo de transporte em toneladas (t)
*
* @return capacidade de carga do veiculo de transporte em toneladas (t)
*/
int Transport::getPayload()
{
return payload;
}
/**
* Configurar a capacidade de carga do veiculo de transporte em
* toneladas (t)
*
* @param payload capacidade de carga do veiculo de transporte em
* toneladas (t)
*/
void Transport::setPayload(int payload)
{
if(payload > 0)
{
Transport::payload = payload;
}
}
/**
* Retornar a velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*
* @return velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*/
int Transport::getSpeed()
{
return speed;
}
/**
* Configurar a velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*
* @param speed velocidade do veiculo de transporte em
* quilometros por hora (km/h)
*/
void Transport::setSpeed(int speed)
{
if(speed > 0)
{
Transport::speed = speed;
}
}
/*
* Retornar os atributos do veiculo de transporte
*
* @return atributos do veiculo de transporte
*/
string* Transport::toString()
{
std::stringstream buffer;
buffer << getName()->c_str() << "\n"
<< "Altura: " << getHeight() << " m\n"
<< "Comprimento: " << getLength() << " m\n"
<< "Capacidade de carga: " << getPayload() << " t\n"
<< "Velocidade: " << getSpeed() << " km/h";
return new string(buffer.str());
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <string>
#include "Transport.h"
using namespace std;
#ifndef AIRTRANSPORT_H
#define AIRTRANSPORT_H
/**
* Classe responsavel pela representacao de um veiculo de transporte aereo
*/
class AirTransport : public Transport
{
private:
/**
* Autonomia de voo do veiculo de transporte aereo em quilometros (km)
*/
int range;
/**
* Envergadura da asa do veiculo de transporte aereo em metros (m)
*/
double wingspan;
public:
/**
* Construtor padrao
*/
AirTransport();
/**
* Retornar a autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*
* @return autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*/
int getRange();
/**
* Configurar a autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*
* @param range autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*/
void setRange(int range);
/**
* Retornar a envergadura da asa do veiculo de transporte aereo em
* metros (m)
*
* @return envergadura da asa do veiculo de transporte aereo em
* metros (m)
*/
double getWingspan();
/**
* Configurar a envergadura da asa do veiculo de transporte aereo em
* metros (m)
*
* @param wingspan envergadura da asa do veiculo de transporte aereo em
* metros (m)
*/
void setWingspan(double wingspan);
/*
* Retornar os atributos do veiculo de transporte aereo
*
* @return atributos do veiculo de transporte aereo
*/
string* toString();
};
#endif
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <cstdlib>
#include <sstream>
#include "AirTransport.h"
using namespace std;
/**
* Construtor padrao
*/
AirTransport::AirTransport()
{
range = 0;
wingspan = 0.0;
}
/**
* Retornar a autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*
* @return autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*/
int AirTransport::getRange()
{
return range;
}
/**
* Configurar a autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*
* @param range autonomia de voo do veiculo de transporte aereo em
* quilometros (km)
*/
void AirTransport::setRange(int range)
{
if(range > 0)
{
AirTransport::range = range;
}
}
/**
* Retornar a envergadura da asa do veiculo de transporte aereo em
* metros (m)
*
* @return envergadura da asa do veiculo de transporte aereo em
* metros (m)
*/
double AirTransport::getWingspan()
{
return wingspan;
}
/**
* Configurar a envergadura da asa do veiculo de transporte aereo em
* metros (m)
*
* @param wingspan envergadura da asa do veiculo de transporte aereo em
* metros (m)
*/
void AirTransport::setWingspan(double wingspan)
{
if(wingspan > 0.0)
{
AirTransport::wingspan = wingspan;
}
}
/*
* Retornar os atributos do veiculo de transporte aereo
*
* @return atributos do veiculo de transporte aereo
*/
string* AirTransport::toString()
{
string* super = Transport::toString();
std::stringstream buffer;
buffer << "Veículo de transporte aéreo: " << super->c_str() << "\n"
<< "Autonomia de voo: " << getRange() << " km\n"
<< "Envergadura da asa: " << getWingspan() << " m\n";
free(super);
return new string(buffer.str());
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <string>
#include "Transport.h"
using namespace std;
#ifndef LANDTRANSPORT_H
#define LANDTRANSPORT_H
/**
* Classe responsavel pela representacao de um veiculo de transporte
* terrestre
*/
class LandTransport : public Transport
{
private:
/**
* Motor do veiculo de transporte terrestre
*/
string* engine;
/**
* Rodas do veiculo de transporte terrestre
*/
string* wheels;
public:
/**
* Construtor padrao
*/
LandTransport();
/**
* Destrutor padrao
*/
~LandTransport();
/**
* Retornar o motor veiculo de transporte terrestre
*
* @return motor veiculo de transporte terrestre
*/
string* getEngine();
/**
* Configurar o motor veiculo de transporte terrestre
*
* @param engine motor veiculo de transporte terrestre
*/
void setEngine(string* engine);
/**
* Retornar as rodas do veiculo de transporte terrestre
*
* @return rodas do veiculo de transporte terrestre
*/
string* getWheels();
/**
* Configurar as rodas do veiculo de transporte terrestre
*
* @param wheels rodas do veiculo de transporte terrestre
*/
void setWheels(string* wheels);
/*
* Retornar os atributos do veiculo de transporte terrestre
*
* @return atributos do veiculo de transporte terrestre
*/
string* toString();
};
#endif
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <cstdlib>
#include <sstream>
#include "LandTransport.h"
using namespace std;
/**
* Construtor padrao
*/
LandTransport::LandTransport()
{
engine = NULL;
wheels = NULL;
}
/**
* Destrutor padrao
*/
LandTransport::~LandTransport()
{
if(engine != NULL)
{
free(engine);
}
if(wheels != NULL)
{
free(wheels);
}
}
/**
* Retornar o motor veiculo de transporte terrestre
*
* @return motor veiculo de transporte terrestre
*/
string* LandTransport::getEngine()
{
return engine;
}
/**
* Configurar o motor veiculo de transporte terrestre
*
* @param engine motor veiculo de transporte terrestre
*/
void LandTransport::setEngine(string* engine)
{
LandTransport::engine = engine;
}
/**
* Retornar as rodas do veiculo de transporte terrestre
*
* @return rodas do veiculo de transporte terrestre
*/
string* LandTransport::getWheels()
{
return wheels;
}
/**
* Configurar as rodas do veiculo de transporte terrestre
*
* @param wheels rodas do veiculo de transporte terrestre
*/
void LandTransport::setWheels(string* wheels)
{
LandTransport::wheels = wheels;
}
/*
* Retornar os atributos do veiculo de transporte terrestre
*
* @return atributos do veiculo de transporte terrestre
*/
string* LandTransport::toString()
{
string* super = Transport::toString();
std::stringstream buffer;
buffer << "Veículo de transporte terrestre: " << super->c_str() << "\n"
<< "Motor: " << getEngine()->c_str() << "\n"
<< "Rodas: " << getWheels()->c_str() << "\n";
free(super);
return new string(buffer.str());
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <string>
#include "Transport.h"
using namespace std;
#ifndef WATERTRANSPORT_H
#define WATERTRANSPORT_H
/**
* Classe responsavel pela representacao de um veiculo de transporte
* maritimo
*/
class WaterTransport : public Transport
{
private:
/**
* Boca do veiculo de transporte maritimo em metros (m)
*/
int beam;
/**
* Calado do veiculo de transporte maritimo em metros (m)
*/
int draught;
public:
/**
* Construtor padrao
*/
WaterTransport();
/**
* Retornar a boca do veiculo de transporte maritimo em metros (m)
*
* @return boca do veiculo de transporte maritimo em metros (m)
*/
int getBeam();
/**
* Configurar a boca do veiculo de transporte maritimo em metros (m)
*
* @param beam boca do veiculo de transporte maritimo em metros (m)
*/
void setBeam(int beam);
/**
* Retornar o calado do veiculo de transporte maritimo em metros (m)
*
* @return calado do veiculo de transporte maritimo em metros (m)
*/
int getDraught();
/**
* Configurar o calado do veiculo de transporte maritimo em metros (m)
*
* @param draught calado do veiculo de transporte maritimo em metros (m)
*/
void setDraught(int draught);
/*
* Retornar os atributos do veiculo de transporte terrestre
*
* @return atributos do veiculo de transporte terrestre
*/
string* toString();
};
#endif
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <cstdlib>
#include <sstream>
#include "WaterTransport.h"
using namespace std;
/**
* Construtor padrao
*/
WaterTransport::WaterTransport()
{
beam = 0;
draught = 0;
}
/**
* Retornar a boca do veiculo de transporte maritimo em metros (m)
*
* @return boca do veiculo de transporte maritimo em metros (m)
*/
int WaterTransport::getBeam()
{
return beam;
}
/**
* Configurar a boca do veiculo de transporte maritimo em metros (m)
*
* @param beam boca do veiculo de transporte maritimo em metros (m)
*/
void WaterTransport::setBeam(int beam)
{
if(beam > 0)
{
WaterTransport::beam = beam;
}
}
/**
* Retornar o calado do veiculo de transporte maritimo em metros (m)
*
* @return calado do veiculo de transporte maritimo em metros (m)
*/
int WaterTransport::getDraught()
{
return draught;
}
/**
* Configurar o calado do veiculo de transporte maritimo em metros (m)
*
* @param draught calado do veiculo de transporte maritimo em metros (m)
*/
void WaterTransport::setDraught(int draught)
{
if(draught > 0)
{
WaterTransport::draught = draught;
}
}
/*
* Retornar os atributos do veiculo de transporte maritimo
*
* @return atributos do veiculo de transporte maritimo
*/
string* WaterTransport::toString()
{
string* super = Transport::toString();
std::stringstream buffer;
buffer << "Veículo de transporte marítimo: " << super->c_str() << "\n"
<< "Boca: " << getBeam() << " m\n"
<< "Calado: " << getDraught() << " m\n";
free(super);
return new string(buffer.str());
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include "Transport.h"
#ifndef NODE_H
#define NODE_H
/**
* Classe responsavel pela representacao de um nodo na lista
*/
class Node
{
private:
/**
* Elemento do nodo
*/
Transport* element;
/**
* Proximo nodo da lista
*/
Node* next;
public:
/**
* Construtor para inicializar o elemento do nodo
*
* @param element elemento do nodo
*/
Node(Transport* element);
/**
* Retornar o elemento do nodo
*
* @return elemento do nodo
*/
Transport* getElement();
/**
* Retornar o proximo nodo da lista
*
* @return proximo nodo da lista
*/
Node* getNext();
/**
* Configurar o proximo nodo da lista
*
* @param next proximo nodo da lista
*/
void setNext(Node* next);
};
#endif
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <cstdlib>
#include "Node.h"
/**
* Construtor para inicializar o elemento do nodo
*
* @param element elemento do nodo
*/
Node::Node(Transport* element)
{
Node::element = element;
Node::next = NULL;
}
/**
* Retornar o elemento do nodo
*
* @return elemento do nodo
*/
Transport* Node::getElement()
{
return element;
}
/**
* Retornar o proximo nodo da lista
*
* @return proximo nodo da lista
*/
Node* Node::getNext()
{
return next;
}
/**
* Configurar o proximo nodo da lista
*
* @param next proximo nodo da lista
*/
void Node::setNext(Node* next)
{
Node::next = next;
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <string>
#include "Node.h"
using namespace std;
#ifndef CATALOG_H
#define CATALOG_H
/**
* Classe responsavel pela representacao de um catalogo de veiculos de
* transporte
*/
class Catalog
{
private:
/**
* Veiculos de transporte
*/
Node* vehicles;
public:
/**
* Construtor padrao
*/
Catalog();
/**
* Destrutor padrao
*/
~Catalog();
/**
* Adicionar um veiculos de transporte ao catalogo
*
* @param transport veiculo de transporte a ser adicionado ao catalogo
*/
void add(Transport* transport);
/*
* Retornar os veiculos de transporte cadastrados
*
* @return veiculos de transporte cadastrados
*/
string* toString();
};
#endif
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <cstdlib>
#include <sstream>
#include "Catalog.h"
using namespace std;
/**
* Construtor padrao
*/
Catalog::Catalog()
{
vehicles = NULL;
}
/**
* Destrutor padrao
*/
Catalog::~Catalog()
{
while(vehicles != NULL)
{
Node* node = vehicles;
vehicles = vehicles->getNext();
free(node);
}
}
/**
* Adicionar um veiculos de transporte ao catalogo
*
* @param transport veiculo de transporte a ser adicionado ao catalogo
*/
void Catalog::add(Transport* transport)
{
if(vehicles == NULL)
{
vehicles = new Node(transport);
}
else
{
Node* node = vehicles;
while(node->getNext() != NULL)
{
node = node->getNext();
}
node->setNext(new Node(transport));
}
}
/*
* Retornar os veiculos de transporte cadastrados
*
* @return veiculos de transporte cadastrados
*/
string* Catalog::toString()
{
Node* node = vehicles;
std::stringstream buffer;
while(node != NULL)
{
string* element = node->getElement()->toString();
buffer << element->c_str() << "\n";
free(element);
node = node->getNext();
}
return new string(buffer.str());
}
/**
* Copyright (C) 2009/2025 - Cristiano Lehrer (cristiano@ybadoo.com.br)
* Ybadoo - Solucoes em Software Livre (www.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 copy of the license is included in the section entitled "GNU
* Free Documentation License".
*/
#include <iostream>
#include "AirTransport.h"
#include "LandTransport.h"
#include "WaterTransport.h"
#include "Catalog.h"
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)
{
Catalog* catalog = new Catalog();
AirTransport* antonov = new AirTransport();
antonov->setName(new string("Antonov An-225"));
antonov->setHeight(18.1);
antonov->setLength(84.0);
antonov->setPayload(275);
antonov->setSpeed(865);
antonov->setRange(4500);
antonov->setWingspan(88.4);
catalog->add(antonov);
LandTransport* belaz = new LandTransport();
belaz->setName(new string("BelAZ 75710"));
belaz->setHeight(8.16);
belaz->setLength(20.6);
belaz->setPayload(450);
belaz->setSpeed(64);
belaz->setEngine(new string("MTU DD 16V4000"));
belaz->setWheels(new string("59/80R63"));
catalog->add(belaz);
WaterTransport* vale = new WaterTransport();
vale->setName(new string("Vale Brasil"));
vale->setHeight(56);
vale->setLength(362);
vale->setPayload(400000);
vale->setSpeed(28);
vale->setBeam(65);
vale->setDraught(23);
catalog->add(vale);
cout << catalog->toString()->c_str() << endl;
delete catalog;
return 0;
}