Вы находитесь на странице: 1из 1

Why GitHub?

Enterprise Explore Marketplace Pricing Search Sign in Sign up

lmarques7 / sistema_bancario Watch 1 Star 1 Fork 7

Code Issues 0 Pull requests 0 Projects 0 Insights

Dismiss
Join GitHub today
GitHub is home to over 36 million developers working together to host and
review code, manage projects, and build software together.

Sign up

Branch: master sistema_bancario / POO - Aula - Sistema Bancário (camadas + herança) / src / br / ufrpe / Find file Copy path
sistema_bancario / negocio / beans / ContaEspecial.java

lmarques7 Removendo Serializable 02f0fcf on 16 Sep 2016

1 contributor

47 lines (39 sloc) 1.34 KB Raw Blame History

1 package br.ufrpe.sistema_bancario.negocio.beans;
2
3 public class ContaEspecial extends Conta {
4 private double limite;
5
6 public ContaEspecial(String numero) {
7 super(numero, 0.0);
8 this.limite = 100.0;
9 }
10
11 public void aumentarLimite(double aumento) {
12 this.limite += aumento;
13 }
14
15 public double getLimite() {
16 return this.limite;
17 }
18
19 public void debitar(double valor) {
20 if (valor < this.saldo + this.limite) {
21 this.saldo = this.saldo - valor;
22 }
23 }
24
25 public void calcularJuros() {
26 if (this.saldo < 0) {
27 // Calculando o valor absoluto dos juros, porque não faz sentido
28 // dos juros serem negativos e o débito ser feito de um valor
29 // negativo torna-se-á um crédito
30 double juros = Math.abs(this.saldo * 0.05);
31 this.debitar(juros);
32 }
33 }
34
35 public static void main(String[] args) {
36 Conta contae = new ContaEspecial("2134-5");
37 contae.creditar(500.0);
38 contae.debitar(550.0);
39 ((ContaEspecial) contae).aumentarLimite(100.0);
40 contae.debitar(75.0);
41 ((ContaEspecial) contae).calcularJuros();
42 System.out.println(contae.getSaldo());
43
44 Conta c = new Conta("1239-7", 55.0);
45 c.getClass();
46 }
47 }

© 2019 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub Pricing API Training Blog About

Вам также может понравиться