Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
4
Indexable
Never
import java.util.Scanner;
import java.util.Scanner;
import java.util.ArrayList;
public class UtopianSimplestProtocol {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String message = scanner.nextLine();
     //   int number = scanner.nextInt();
        Sender sender = new Sender();
        Receiver receiver = new Receiver();
        for (int i = 0; i < message.length(); i++){
            char packet = message.charAt(i);
                sender.network(packet,receiver);
        }
        receiver.show();

    }

    public static class Sender{
        public void network(char packet,Receiver receiver){
            dataLayer(packet,receiver);
        }
        public void dataLayer(char packet,Receiver receiver){
            phisicalLayer(packet,receiver);
        }
        public void phisicalLayer(char packet,Receiver receiver){
            receiver.network(packet);
        }
    }
    public static class Receiver{
        ArrayList<Character> message = new ArrayList<Character>();
        public void network(char packet){
            dataLayer(packet);
        }
        public void dataLayer(char packet){
            phisicalLayer(packet);
        }
        public void phisicalLayer(char packet){
            message.add(packet);
        }
        public void show(){
            for (Character item : message) {
                System.out.println(item);
            }
        }
    }


}