This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Observer { | |
void notify(String message); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Observable { | |
void addObserver(Observer observer); | |
void removeObserver(Observer observer); | |
void notifyObserver(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
public class NoticeObservable implements Observable { | |
private List<Observer> observerList = new ArrayList<>(); | |
private String message = "Notice... !"; | |
@Override | |
public void addObserver(Observer observer) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserMan implements Observer { | |
private Observable observable; | |
@Override | |
public void notify(String message) { | |
System.out.println(message + " UserMan Mesaj Geldi."); | |
} | |
public void removeObserver(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserWoman implements Observer { | |
private Observable observable; | |
public UserWoman() { | |
} | |
public void setObservable(Observable observable) { | |
this.observable = observable; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
UserMan userMan = new UserMan(); | |
UserWoman userWoman = new UserWoman(); | |
NoticeObservable noticeObservable = new NoticeObservable(); | |
userWoman.setObservable(noticeObservable); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Computer { | |
void name(); | |
void since(int year); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mac implements Computer { | |
@Override | |
public void name() { | |
System.out.println("Bilgisayarın Markası Mac"); | |
} | |
@Override | |
public void since(int year) { | |
System.out.println(year + " senesinde alınmış."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Asus implements Computer { | |
@Override | |
public void name() { | |
System.out.println("Bilgisayarın Markası Asus"); | |
} | |
@Override | |
public void since(int year) { | |
System.out.println(year + " senesinde alınmış."); |