Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------1ви файл ILibraryBook
- public interface ILibraryBook {
- public void get(Reader rdr);
- public void get();
- }
- ------------2ри файл IReader
- public interface IReader {
- public void get(LibraryBook obj);
- public void ret(LibraryBook obj);
- }
- -----------3ти файл Applicant
- import java.util.GregorianCalendar;
- public class Applicant {
- private String name;
- private GregorianCalendar date;
- private double uspeh;
- public Applicant(GregorianCalendar birth, String name, double uspeh)
- {
- this.name = name;
- this.date = birth;
- this.uspeh = uspeh;
- }
- public String getName()
- {
- return this.name;
- }
- public void setName(String name)
- {
- this.name = name;
- }
- public GregorianCalendar getDate()
- {
- return this.date;
- }
- public void setDate(GregorianCalendar birth)
- {
- this.date = birth;
- }
- public double getUspeh()
- {
- return this.uspeh;
- }
- public void setUspeh(double uspeh)
- {
- this.uspeh = uspeh;
- }
- public String toString()
- {
- return this.name + " " + this.date + " " + this.uspeh + " ";
- }
- }
- ---------------------4ти файл Student
- import java.util.GregorianCalendar;
- public class Student extends Applicant implements Comparable<Object>{
- private String FN;
- public Student(String name, String FN) {
- super(new GregorianCalendar(),name,0.0);
- this.FN = FN;
- }
- public Student(GregorianCalendar date, String name, double uspeh, String FN) {
- /*super.setDate(date);
- super.setName(name);
- super.setUspeh(uspeh);*/
- super(date,name,uspeh);
- this.FN = FN;
- }
- public boolean equals (Object r) {
- return this.FN.equals(((Student)r).FN);
- }
- public String getFN() {
- return this.FN;
- }
- public void setFN(String FN) {
- this.FN = FN;
- }
- public String toString() {
- return super.toString() + " " + this.FN;
- }
- public int compareTo(Object r) {
- return this.FN.compareTo(((Student)r).FN);
- }
- }
- ------------------------------5ти файл Reader
- import java.util.GregorianCalendar;
- public class Reader extends Student implements IReader,Comparable<Object>{
- private LibraryBook library_book_obj= new LibraryBook("");
- public Reader(String nm,String fn) {
- super(nm,fn);
- }
- public Reader(GregorianCalendar date, String name, double uspeh, String FN) {
- super(date,name,uspeh,FN);
- }
- public LibraryBook getLibraryBook() {
- return this.library_book_obj;
- }
- public String toString() {
- return super.toString() + " " + this.library_book_obj.toString();
- }
- public int compareTo(Object r) {
- return super.compareTo(r);
- }
- public void get(LibraryBook lb) {
- this.library_book_obj = lb;
- }
- public void ret(LibraryBook lb) {
- lb.ret();
- library_book_obj = null;
- }
- }
- ---------------------------6ти файл LibraryBook
- public class LibraryBook implements ILibraryBook,Comparable<Object>{
- private Reader reader_obj = new Reader(null, null, 0, null);
- private String book_name;
- private boolean status;
- public LibraryBook(String bn) {
- this.book_name = bn;
- }
- public LibraryBook(String bn,boolean st) {
- this.book_name = bn;
- this.status = st;
- }
- public Reader getReader() {
- return reader_obj;
- }
- public String getBookName() {
- return this.book_name;
- }
- public void setBookName(String book_name) {
- this.book_name = book_name;
- }
- public String getStatusText() {
- if(this.status) {
- return "zaeta";
- }
- return "svobodna";
- }
- public boolean getStatus() {
- return this.status;
- }
- public void setStatus(boolean status) {
- this.status = status;
- }
- public String toString() {
- return reader_obj.toString() + " " + book_name + " " + this.getStatusText();
- }
- public int compareTo(Object r) {
- return this.compareTo((LibraryBook)r).toString()); // <-----тук има грешка и подчертава всичко включително след this.
- }
- public void get(Reader rdr) {
- this.reader_obj = null;
- this.status = true;
- }
- public void ret() {
- this.reader_obj = null;
- this.status = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement