Datasets:
ArXiv:
License:
Download data/test/Hugo-Gao/Design-pattern/Observer/src/bookstoreex/Student.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 785 Bytes
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/main/data/test/Hugo-Gao/Design-pattern/Observer/src/bookstoreex/Student.java
- Command line
-
hf download hf://datasets/RepoFusion/Stack-Repo/data/test/Hugo-Gao/Design-pattern/Observer/src/bookstoreex/Student.java
-
curl -L -o Student.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/main/data/test/Hugo-Gao/Design-pattern/Observer/src/bookstoreex/Student.java
785 Bytes
| package bookstoreex; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| /** | |
| * Created by Administrator on 2017/6/16. | |
| */ | |
| public class Student implements DisplayElement , Observer | |
| { | |
| private String name; | |
| private List<String> hasBooks; | |
| private Observable observable; | |
| public Student(String name,Observable observable) | |
| { | |
| this.name = name; | |
| this.hasBooks = new ArrayList<>(); | |
| this.observable = observable; | |
| observable.registerObserver(this); | |
| } | |
| public void update(String book) | |
| { | |
| hasBooks.add(book); | |
| System.out.print(name+"涔板埌浜嗕功<"+book+"> "); | |
| display(); | |
| } | |
| public void display() | |
| { | |
| System.out.println(name+"鏈変功->"+hasBooks.toString()); | |
| } | |
| } | |