Repository navigation
Sheffield | 26-Java-June | Hassan Osman | Sprint 4 | Rental Summary Generator - #74
Open
HassanOHOsman wants to merge 42 commits into
Open
HassanOHOsman wants to merge 42 commits into
HassanOHOsman wants to merge 42 commits into
Conversation
…h the use of enum the validation requirement is now met.
…pp instead so that we could create 12 rentals for 1 year
…d to avoid hard-cosing
2. Work out the boolean expression for paid and feed the variable paid into th the rental constructor.
…talGenerator class by: 1. formulating the mathematical expression that is meant to represent monthlyCapital and monthlyInterest. 2. Feed these 2 variables inside the rental constructor.
…teRentals method, by: 1) working out a boolean expression to represent paid var which will be feed to the rental object as arg. 2) working out the dueDate relying on the Contract class's field getStartDate() and plusMonths() method.
… method: 1. Move monthlyCapital and monthlyInterest outside the for loop since they don't rely on index (i). 2. ensure to add each rental instance to the rentals list.
… (to be implemented).
…2 methods signatures into it (to be implemented).
…talSummary can have access to those fields and create isntance of RentalSummary
…class since it's no longer in use.
… contract is complete and thus in this case a message saying so to be logged to the console.
…(s) is added to the summary.
…orrect worked-out value is added to the summary.
…at the correct worked-out value is added to the summary.
…l then act as the next due rent, rather than the first paid rent
…RentalSummary method inside RentalSummaryService class is able to print a meaningful text with detailing the rental summary.
…RentalSummary method inside RentalSummaryService class is able to print a meaningful text with detailing the rental summary.
…ummary method inside RentalSummaryService class is able to print a meaningful text with detailing the rental summary.
…what I've implemented so far
…ing() method inside RentalSummary class.
…amount and interest amount are displayed.
…formatted to 2 decimal places only.
jacknewman1995
suggested changes
Sep 4, 2026
| private double carPrice; | ||
|
|
||
| enum ContractLengthYears { | ||
| One_YEAR, |
| THREE_YEARS | ||
| } | ||
|
|
||
| private ContractLengthYears contractLengthYears; |
There was a problem hiding this comment.
Lets move this up with the rest of the fields
|
|
||
| @Override | ||
| public String toString(){ | ||
| return "Customer: " + customerName + |
There was a problem hiding this comment.
Your IDE's generate tostring command might help here
| .mapToDouble(Rental:: getInterestAmount) | ||
| .sum(); | ||
|
|
||
| int numberOfRemainingRentals = (int) rentals.stream() |
Author
There was a problem hiding this comment.
Because it gives "long" in the end and I wanted it as "int" which is a smaller whole number value type and thus the conversion has to be manual/ explicit.
Author
|
Hi Jack! Thank you for reviewing my work. I now have:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
In this PR, I implemented the Rental Summary Generator for 1-year and 3-year contracts. Added contract and rental models, rental calculation generators, summary generation using streams, payment/remaining rental tracking, completed contract handling, and human-readable console output. Also added toString() methods to make rental and summary information easier to read.