2017-05-07 18 views
-5

私はライブラリシステムを作成しようとしています。JavaのUmlクラス図

どのクラスを抽象化する必要がありますか?もっとクラスが必要ですか?

here is how far i got

+1

は、スタックオーバーフローへようこそ!宿題の助けを求めているようです。それ自体に問題はありませんが、これらのことを守ってください(http://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions/338845#338845)、それに応じて質問を編集してください。 –

答えて

1

はいあなたは多くのクラスを必要とする、あなたのクラスは次のようになります。

class Person{ 
    //attributes, getters and setters 
} 

class User extends Person{ 
    //attributes, getters and setters 
} 

class Members extends Person{ 
} 

class Librarian extends Person{ 
} 

class Book{ 
    //attributes, getters and setters 
} 
0
public class Person { 
    private String FirstName; 
    private String LastName; 
    private String Gender; 
    private String Contact; 
    private String Email; 

    public Person() { 
    } 

    public Person(String FirstName, String LastName, String Gender, String Contact, String Email) { 
     this.FirstName = FirstName; 
     this.LastName = LastName; 
     this.Gender = Gender; 
     this.Contact = Contact; 
     this.Email = Email; 
    } 

    public String getFirstName() { 
     return FirstName; 
    } 

    public void setFirstName(String FirstName) { 
     this.FirstName = FirstName; 
    } 

    public String getLastName() { 
     return LastName; 
    } 

    public void setLastName(String LastName) { 
     this.LastName = LastName; 
    } 

    public String getGender() { 
     return Gender; 
    } 

    public void setGender(String Gender) { 
     this.Gender = Gender; 
    } 

    public String getContact() { 
     return Contact; 
    } 

    public void setContact(String Contact) { 
     this.Contact = Contact; 
    } 

    public String getEmail() { 
     return Email; 
    } 

    public void setEmail(String Email) { 
     this.Email = Email; 
    } 

} 
public class User extends Person { 
    private String Password; 
    private String Username; 
    boolean isEnabled; 

    public User() { 
    } 

    public User(String Password, String Username, boolean isEnabled) { 
     this.Password = Password; 
     this.Username = Username; 
     this.isEnabled = isEnabled; 
    } 

    public String getPassword() { 
     return Password; 
    } 

    public void setPassword(String Password) { 
     this.Password = Password; 
    } 

    public String getUsername() { 
     return Username; 
    } 

    public void setUsername(String Username) { 
     this.Username = Username; 
    } 

    public boolean isIsEnabled() { 
     return isEnabled; 
    } 

    public void setIsEnabled(boolean isEnabled) { 
     this.isEnabled = isEnabled; 
    } 

} 
public class Guest extends User { 

    public Guest() { 
    } 

    public Guest(String Password, String Username, boolean isEnabled) { 
     super(Password, Username, isEnabled); 
    } 

    public void App(){ 

    } 
    } 
public class Members extends User{ 

    public Members() { 
    } 

    public Members(String Password, String Username, boolean isEnabled) { 
     super(Password, Username, isEnabled); 
    } 

} 
public class Libararian extends User { 

    public Libararian() { 

    } 
    public Libararian(String Password, String Username, boolean isEnabled) { 
     super(Password, Username, isEnabled); 
    } 

} 
public class Book { 
    private String Title; 
    private String Publisher; 
    private String Category; 

    public Book(String Title, String Publisher, String Category) { 
     this.Title = Title; 
     this.Publisher = Publisher; 
     this.Category = Category; 
    } 

    public Book() { 
    } 

    public String getTitle() { 
     return Title; 
    } 

    public void setTitle(String Title) { 
     this.Title = Title; 
    } 

    public String getPublisher() { 
     return Publisher; 
    } 

    public void setPublisher(String Publisher) { 
     this.Publisher = Publisher; 
    } 

    public String getCategory() { 
     return Category; 
    } 

    public void setCategory(String Category) { 
     this.Category = Category; 
    } 

} 
+0

複数レベルの継承のため、Guest()、Members()、Librarian()クラスはすべてPerson()クラスの属性を持ちます。また、User()クラスすべてのPerson()クラス属性を持ちます。私はこれがあなたのコードを書くべきだと思います。 – bixhopm