Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. private int numeroReal1;
  2. private int numeroImaginario1;
  3. private int numeroReal2;
  4. private int numeroImaginario2;
  5.  
  6. public Complexo(int numeroReal1, int numeroImaginario1, int numeroReal2, int numeroImaginario2) {
  7. this.numeroReal1 = numeroReal1;
  8. this.numeroImaginario1 = numeroImaginario1;
  9. this.numeroReal2 = numeroReal2;
  10. this.numeroImaginario2 = numeroImaginario2;
  11. }
  12.  
  13. public int getNumeroReal1() {
  14. return numeroReal1;
  15. }
  16.  
  17. public void setNumeroReal1(int numeroReal1) {
  18. this.numeroReal1 = numeroReal1;
  19. }
  20.  
  21. public int getNumeroReal2() {
  22. return numeroReal2;
  23. }
  24.  
  25. public void setNumeroReal2(int numeroReal2) {
  26. this.numeroReal2 = numeroReal2;
  27. }
  28.  
  29. public int getNumeroImaginario1() {
  30. return numeroImaginario1;
  31. }
  32.  
  33. public void setNumeroImaginario1(int numeroImaginario1) {
  34. this.numeroImaginario1 = numeroImaginario1;
  35. }
  36.  
  37. public int getNumeroImaginario2() {
  38. return numeroImaginario2;
  39. }
  40.  
  41. public void setNumeroImaginario2(int numeroImaginario2) {
  42. this.numeroImaginario2 = numeroImaginario2;
  43. }
  44.  
  45. public int somarComplexos()
  46. {
  47. return (numeroReal1 + numeroImaginario1) + (numeroReal2 + numeroImaginario2);
  48. }
  49.  
  50. public static void main(String[] args) {
  51. Complexo somaComplexo1 = new Complexo(4, 6, 5, 3);
  52. System.out.println("Numero Real1: " + somaComplexo1.getNumeroReal1() + " Numero imaginario1: " + somaComplexo1.getNumeroImaginario1() + "i");
  53. System.out.println("Numero Rea2: " + somaComplexo1.getNumeroReal2() + " Numero imaginario1: " + somaComplexo1.getNumeroImaginario2() + "i");
  54. System.out.println("Soma Complexos: " + somaComplexo1.somarComplexos());
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement