Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public class Main {
  2. public static void main(String[] args){
  3. Komorka x = new Komorka();
  4. for(int i=0; i<10; i++){
  5. x.call("123-555-777");
  6. }
  7. x.show();
  8. x.call("12324-7831-31");
  9. x.show();
  10. x.call("3213124421");
  11. x.call("666-111-2222");
  12. x.show();
  13. }
  14. }
  15.  
  16.  
  17.  
  18. class Telefon {
  19. String inter;
  20. String color;
  21. void call(String number){
  22. System.out.println(number);
  23. }
  24. }
  25.  
  26.  
  27.  
  28. class Komorka extends Telefon {
  29. String[] last = new String[10];
  30. int x=0;
  31. void call(String number){
  32. System.out.println(number);
  33. if(x==last.length){
  34. for(int i=0; i<last.length-1; i++)
  35. last[i]=last[i+1];
  36. last[9]=number;
  37. }
  38. else {
  39. last[x] = number;
  40. x++;
  41. }
  42. }
  43. void show(){
  44. for(int i=0; i<last.length; i++)
  45. System.out.print(last[i]+" ");
  46. System.out.println();
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement