Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package ed_ficha4;
  7.  
  8. import java.util.Iterator;
  9.  
  10. /**
  11. *
  12. * @author nuno_
  13. */
  14. public class DezReaisMutavel extends DezReais implements Iterable<Double>{
  15. private final int TAMANHO = 10;
  16. private Double []tab = new Double[TAMANHO];
  17. private int last = 0;
  18. private int modificacoes = 0;
  19.  
  20.  
  21. public void remove(int pos){
  22.  
  23. int j;
  24. modificacoes ++;
  25. System.out.println("last: " + last + " pos: " + pos);
  26.  
  27. for (j = pos ; j < last - 1; j++){
  28. tab[j] = tab[j+1];
  29.  
  30. }
  31. last--;
  32. }
  33.  
  34. public void acrescenta(Double valor){
  35. modificacoes++;
  36. add(valor);
  37. }
  38.  
  39. public int getModificacoes (){return modificacoes;}
  40.  
  41. @Override
  42. public Iterator<Double> iterator() {
  43. return new ItDezReaisMutavel(this);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement