Comece agoraComece grátis

POJO, wrappers e java.math

Toda grande missão começa com um bom lançamento! Neste exercício, você vai lançar uma classe Rocket que já foi importada para você.

Pronto para a decolagem?

Este exercicio faz parte do curso

Tipos de Dados e Exceções em Java

Ver curso

Instruções do exercicio

  • Crie uma instância do POJO Rocket.
  • Defina o campo thrust de Rocket como "7770000" em um BigDecimal usando o setter correspondente.
  • Defina o campo manned como true usando o setter .setManned().

exercicio interativo prático

Tente este exercicio completando este código de exemplo.

public class Launch {

	public static void main(String[] args) {
    	// Create an instance of the Rocket POJO
		Rocket rocket = ____ ____();
		rocket.setName("Saturn");
        // Set the thrust field to as a BigDecimal
		rocket.setThrust(____ ____("7770000"));
        // Set the rocket's manned Boolean wrapper field to true
		rocket.____(____);
		fire(rocket);
	}

	public static void fire(Rocket r) {
		BigDecimal newtons = r.getThrust().divide(new BigDecimal(224));
		System.out.println("We have liftoff of: " + r.getName());
		System.out.print("Thrust is: " + newtons + " newtons of energy");
	}
}
Editar e Executar Código