Feedback for these lessons is very much welcome. If you like or hate something about a lesson let us know, either on GitHub, via Mail or just tell us in person ;)
x
B04 - User of the Library
After we created a Library and Book class we want to create a user to use this library.1 2
Step 1
Create the following classes:
Libraryin the solution folderBookin the “Media” folderUserAccountin the “User” folder
Step 2
Fill the UserAccount class with the following members:
- two
stringproperties: “Name” and “EMail” - a
longproperty “ID”- all of them have a
getand aprivate set
- all of them have a
- a
privatearray ofBookas field “borrowedBooks”- the user can only borrow 5 books at a time
- a constructor with three parameters: name, email and id
Add to the Library class the following members:
- a
privatearray field ofUserAccount“users”- the library can only have 100 users at a time
- a
private intfield “userCount” that contains the number users already registered - method
RegisterUserwith two parameters: name and email
Add to the Book class the following member:
- a
private UserAccountfield “borrowedTo”
Step 3
Implement the “Register” method. It should add a new user to the array of users. Create a new user with the given parameters.
Hint: We don’t get the id as parameter in this method. What can you use as an id for the constructor?
Step 4
Write for all created classes, methodes, properties and fields documentation comments.