Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package listacomp2;
- public class entrada {
- int day, month, year, hour, minute, room, yearc, mc, dc;
- float value;
- entrada(horario h, data d, int sala, float valor){
- day = d.dia;
- month = d.mes;
- year = d.ano;
- hour = h.horas;
- minute = h.minutos;
- room = sala;
- value = valor;
- }
- void calculadesconto(entrada e, int cd, int cm, int ca) {
- yearc = e.year - ca;
- if(yearc > 12) {
- System.out.println("Sem desconto, maior de 12 anos.");
- }
- else if(yearc == 12 && e.month > cm) {
- System.out.println();
- }
- else if(yearc == 12 && cm == e.month) {
- if(cd == e.day) {
- System.out.println();
- }
- if(cd > e.day) {
- e.value = e.value/2;
- }
- }
- else {
- e.value = e.value/2;
- }
- }
- void calculadescontohorario(entrada e) {
- if(e.hour>16) {
- System.out.println("Sem desconto, já passou da hora.");
- }
- else if (e.minute > 30) {
- System.out.println();
- }
- else {
- e.value = (e.value/10)* 9;
- }
- }
- void tostring(entrada e) {
- System.out.println("Data do filme => Dia: " + e.day + "/" + e.month + "/" + e.year);
- System.out.println("Horario do filme => " + e.hour + ":" + e.minute + "h");
- System.out.println("Sala " + e.room);
- System.out.println("Valor do ingresso: R$" + e.value);
- }
- public static void main (String [] args) {
- horario h = new horario(16,25);
- data d = new data(13,2,2018);
- entrada e = new entrada(h,d,7,(float) 20.00);
- e.calculadesconto(e,12,3,2006);
- e.calculadescontohorario(e);
- e.tostring(e);
- }
- }
- class data{
- int dia, mes, ano;
- data(int d, int m, int a){
- dia = d;
- mes = m;
- ano = a;
- }
- }
- class horario{
- int horas, minutos;
- horario(int h, int min){
- horas = h;
- minutos = min;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement