Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args){
- Komorka x = new Komorka();
- for(int i=0; i<10; i++){
- x.call("123-555-777");
- }
- x.show();
- x.call("12324-7831-31");
- x.show();
- x.call("3213124421");
- x.call("666-111-2222");
- x.show();
- }
- }
- class Telefon {
- String inter;
- String color;
- void call(String number){
- System.out.println(number);
- }
- }
- class Komorka extends Telefon {
- String[] last = new String[10];
- int x=0;
- void call(String number){
- System.out.println(number);
- if(x==last.length){
- for(int i=0; i<last.length-1; i++)
- last[i]=last[i+1];
- last[9]=number;
- }
- else {
- last[x] = number;
- x++;
- }
- }
- void show(){
- for(int i=0; i<last.length; i++)
- System.out.print(last[i]+" ");
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement