Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 3.25 KB

File metadata and controls

57 lines (48 loc) · 3.25 KB

IMPORTANT! Completed tasks are evaluate at the final result and the manner of applying the knowledge gained in the course

Required Reading

Must Read

  • Builder Pattern (Well described in Effective Java, 2nd edition)
  • Command Pattern (Will help in web development)
  • Chain of Responsibility Pattern (Will help in web development - Servlet Filters)
  • Model View Controller (described In Applied Java Patterns)

Задачи

  1. Factory
    Create an CodecFactory which should be responsible for the creation of different type of Codec objects (JSONCodec, XMLCodec) There should be 2 implementations of this Factory:

    • By using regular instantiation with "new"
    • By using Reflection
  2. Singleton
    The Design Pattern Singleton should be realized. Create a class called Singleton*.*The class should have a private constructor only. The class should be implemented in an appropriate way such that only a single instance of it should be created (i.e. no more than one instance should be instantiated in the memory).

//constructor  
private Singleton() {  
  System.out.println("Singleton created");  
}  
  1. Да се направи Builder, който e отговорен за създаването на следния обект:
public final class Order {
  private Long orderId;
  private String customerName;
  private String customerAddress;
  private Date orderCreationDate; 
  private Date orderDeliveryDate; 
  private List<OrderItem> items;
}

public final class OrderItem {
  private String productName; 
  private String measureUnit;
  private Double quantity; 
  private Double price; 
}

Описание: Да се напише тест на метод, който определя дали order'a е доставен със забавяне или не.

  1. Да се направи Adapter на InputStream, който да позволява използването единствено на int read(byte[] buf, int offset, int length) метода.

  2. Observer
    Да се направи програма за поддържане на статистика на стоки. Трябва да има един клас, който да поддържа статистика за наличните стоки и един, в който има списък с продадените стоки (тези, които вече не са налични). Класът който е регистриран като слушател да следи за премахване на стари или добавяне на нови стоки.