Lab Assignment 1 (1)
Lab Assignment 1 (1)
1
Make sure you have downloaded the IntelliJ project les for the assignment. Use this template to
complete your answer.
The coursework is out of 50 marks, 30 marks for question 1 and 20 marks for question 2
Question 1: BookList (30 marks)
While writing your answer to question 1 make use of BookMain to test your solutions to the
various parts of the question. This class won’t be marked. You will also use the Book and
BookCollection classes in this question.
1. Complete the Book class. It should have the following private properties. You class should
include a constructor with arguments for each of these properties. Also create getters and setters
for each property
• title (string)
• author (String)
• ISBN (long)
• pages (int)
• copiesAvailable (int)
• copiesOnLoan (int)
[2 marks]
2. Complete the BookCollection constructor so that it loads the le path argument as a File. Then
use a Scanner to read in the le and populate the books arrayList. When complete books should
have 100 items in it.
Hint: You will need to skip over the rst line of the le (the column headers), otherwise you will get
an error.
[6 marks]
3. Complete the function getAuthors so that it returns a HashSet of all the authors in books.
[5 marks]
4. Complete the function getLongBooks so it returns an ArrayList of Books which have over 750
pages in them
[5 marks]
5. Complete the function getBookByTitle so it returns the Book object for the given title. If a title
not in the list is given return null.
[5 marks]
6. Complete the function getMostPopularBooks which returns an array of the 10 most popular
books (That is those that currently have most copies on loan).
[7 marks]
fi
fi
fi
fi
fi
Question 2: Deck of cards (20 marks)
In this question you will complete the Hand class and SortCards class. Spend some time
analysing the Card, Deck, Hand and SortCards classes.
Hint: Card has a method getNumericValue that will convert the String value of the card to an
integer for easy comparison. In this implementation Aces are the highest value.
Base your determination of the rank on the classic poker hands. See the code and the image
below for a guide to examples of the 10 ranks these. Using the SortCards class you completed
above the cards of the hand are sorted. This will make this task much easier!
Again, use the main method in CardMain to test your code as you develop your solution. You
should also make use of the dealSpeci cCard method in deck. This will help you to deal speci c
hands that you can check your code against.
fi
fi