Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ZCOMM1;
- // Задатак ZCOMM1: Додати програм на месту три тачке како би се добила порука:
- // Danas je lep dan.
- class Client{
- Receiver rec;
- Command cm;
- Client(){
- rec = new Receiver();
- cm = new ConcreteCommand(rec);
- }
- Command getCommand(){return cm;}
- public static void main(String[] args) {
- Client cl = new Client();
- Invoker inv = new Invoker(new ConcreteCommand(cl.rec));
- inv.Execute();
- }
- }
- class Invoker{
- Command com;
- Invoker(Command com1) {
- com = com1;
- }
- void Execute() {
- com.Execute();
- }
- }
- interface Command{
- void Execute();
- }
- class ConcreteCommand implements Command{
- Receiver rec;
- ConcreteCommand(Receiver rec1) {
- rec = rec1;
- }
- @Override
- public void Execute() {
- rec.Action();
- }
- }
- class Receiver{
- void Action(){System.out.println("Danas je lep dan.");}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement