Guest User

Contas com atributos Statico

a guest
Aug 11th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. package aula3pratica1;
  2.  
  3. public class Conta
  4. {
  5.  
  6. static int totContas;
  7. static double valorTotalContas;
  8. String nomeBanco;
  9. String nomeGerente;
  10.  
  11.  
  12. /**public void contas(int totContas, double valorTotalContas,String nomeBanco, String nomeGerente)
  13. {
  14. this.nomeBanco= nomeBanco;
  15. this.nomeGerente = nomeGerente;
  16. }
  17. */
  18. public static int getTotContas()
  19. {
  20. return totContas;
  21. }
  22.  
  23. public static void setTotContas(int totContas)
  24. {
  25. Conta.totContas = totContas + 1;
  26. }
  27.  
  28. public static double getValorTotalContas()
  29. {
  30. return valorTotalContas;
  31. }
  32.  
  33. public static void setValorTotalContas(double valorTotalContas)
  34. {
  35.  
  36. Conta.valorTotalContas = valorTotalContasA;
  37. }
  38.  
  39. public String getNomeBanco()
  40. {
  41. return nomeBanco;
  42. }
  43.  
  44. public void setNomeBanco(String nomeBanco)
  45. {
  46. this.nomeBanco = nomeBanco;
  47. }
  48.  
  49. public String getNomeGerente()
  50. {
  51. return nomeGerente;
  52. }
  53.  
  54. public void setNomeGerente(String nomeGerente)
  55. {
  56. this.nomeGerente = nomeGerente;
  57. }
  58.  
  59. }
  60.  
  61. package aula3pratica1;
  62.  
  63. public class Principal
  64. {
  65.  
  66. public static void main(String[] args)
  67. {
  68.  
  69. Conta c1 = new Conta();
  70. c1.setNomeBanco("Banco A");
  71. c1.setNomeGerente("Gerente A");
  72. Conta.setTotContas(2);
  73. Conta.setValorTotalContas(1200);
  74. System.out.println("Nome Banco:" + c1.nomeBanco + "\nNome Gerente: " + c1.nomeGerente
  75. + "\nTotal de Contas:" + Conta.totContas + "\nValor Total:" + Conta.valorTotalContas);
  76.  
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment