Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package atividade;
- /**
- *
- * @author Thiago Filipe
- */
- public class Data {
- private int dia;
- private int mes;
- private int ano;
- public int getDiaFDP(){
- return this.dia;
- }
- public void setDiaCarai(int dia){
- this.dia = dia;
- }
- public int getMesFDP(){
- return this.mes;
- }
- public void setMesCarai(int mes){
- this.mes = mes;
- }
- public int getAnoFDP(){
- return this.ano;
- }
- public void setAnoCarai(int ano){
- this.ano = ano;
- }
- public String toStringFormated(){
- // Segurança adicional
- String dataFormated = "";
- if (this.dia > 0 && this.mes > 0 && this.ano > 0){
- dataFormated = this.dia + "/" + this.mes + "/" + this.ano;
- }
- return dataFormated;
- }
- public boolean isValid(){
- if (this.dia > 0 && this.dia <= 31){
- if (this.mes > 0 && this.mes <= 12){
- return true; // a data eh valida.
- }
- }
- return false; // se chegou aqui, os ifs foram falso.
- }
- }
Add Comment
Please, Sign In to add comment