1
I want to prevent an object from being instantiated with a certain value (for example, prevent a "battery" object from having a negative value or above 100). How can I prevent the instance from occurring? Code example:
import java.util.Scanner;
public class Fotocopiadora{
    private String modelo; // essa string não deve ser nula
    private int quantTinta;
    private String proprietario;
    public Fotocopiadora(String modelo, String proprietario){
        this.proprietario = proprietario;
        this.quantTinta = 100;
        this.modelo = ((modelo != null) && (!modelo.isEmpty())) ? modelo : "default"; // usado como substituição ao impedimento de instância
    }
}
Man, that’s right, thanks
– Arthur Siqueira