Label

Thứ Tư, 3 tháng 11, 2010

Question 2 - Interface's Exercise

public interface TimeClient {
public void setTime(int hour, int minute, int second);
public void setDate(int day, int month, int year);
public void setDateAndTime(int day, int month, int year,
int hour, int minute, int second);
}

Suppose that you have written a time server, which periodically notifies its clients of the current date and time. Write an interface that the server could use to enforce a particular protocol on its clients.

Trong ví dụ này, đây là lớp interface được TimeServer implements,  tại sao ko là một interface từ TimeServer được lớp TimeClient triển khai, đúng theo tinh thần đã học ở đầu lesson interface, là tạo 1 protocol chung cho các nhà lập trình riêng biệt, không cầ n biết gì về công việc của nhau và hợp tác thông qua interfaces để tạo sản phẩm???

Không có nhận xét nào:

Đăng nhận xét