Skip to content

Sheffield | 26-Java-June | Hassan Osman | Sprint 4 | Rental Summary Generator - #74

Open
HassanOHOsman wants to merge 42 commits into
CodeYourFuture:mainfrom
HassanOHOsman:backlog/rental-summary-generator
Open

HassanOHOsman wants to merge 42 commits into
CodeYourFuture:mainfrom
HassanOHOsman:backlog/rental-summary-generator

Conversation

@HassanOHOsman

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

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.

…h the use of enum the validation requirement is now met.
…pp instead so that we could create 12 rentals for 1 year
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.
…2 methods signatures into it (to be implemented).
…talSummary can have access to those fields and create isntance of RentalSummary
… contract is complete and thus in this case a message saying so to be logged to the console.
…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.
@HassanOHOsman HassanOHOsman added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 4 Assigned during Sprint 4 of this module labels Aug 14, 2026

@jacknewman1995 jacknewman1995 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

private double carPrice;

enum ContractLengthYears {
One_YEAR,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caps for enums

THREE_YEARS
}

private ContractLengthYears contractLengthYears;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this up with the rest of the fields


@Override
public String toString(){
return "Customer: " + customerName +

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your IDE's generate tostring command might help here

.mapToDouble(Rental:: getInterestAmount)
.sum();

int numberOfRemainingRentals = (int) rentals.stream()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the cast?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@HassanOHOsman

Copy link
Copy Markdown
Author

Hi Jack! Thank you for reviewing my work. I now have:

  1. capitalised the enum - One_YEAR.
  2. moved the field in contractLengthYears at the top with the rest of all fields in the class.
  3. Generated toString() method using my IntelliJ IDEA instead.
  4. Explained why I did the explicit casting for int numberOfRemainingRentals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 4 Assigned during Sprint 4 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants