Skip to content

Commit b28dbe2

Browse files
authored
Changing String format for String concatenation on reference resolutions of concept exercises (#2744)
1 parent 16209ef commit b28dbe2

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

exercises/concept/booking-up-for-beauty/.meta/src/reference/java/AppointmentScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public boolean isAfternoonAppointment(LocalDateTime appointmentDate) {
2323

2424
public String getDescription(LocalDateTime appointmentDate) {
2525
var formatter = DateTimeFormatter.ofPattern("EEEE, MMMM d, yyyy, 'at' h:mm a", Locale.ENGLISH);
26-
return String.format("You have an appointment on %s.", formatter.format(appointmentDate));
26+
return "You have an appointment on " + formatter.format(appointmentDate) + ".";
2727
}
2828

2929
public LocalDate getAnniversaryDate() {

exercises/concept/calculator-conundrum/.meta/src/reference/java/CalculatorConundrum.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public String calculate(int operand1, int operand2, String operation) {
1919
throw new IllegalOperationException("Division by zero is not allowed", e);
2020
}
2121
}
22-
default -> throw new IllegalOperationException(String.format("Operation '%s' does not exist", operation));
22+
default -> throw new IllegalOperationException("Operation '" + operation + "' does not exist");
2323
}
2424

25-
return String.format("%d %s %d = %s", operand1, operation, operand2, result);
25+
return String.valueOf(operand1) + " " + String.valueOf(operation) + " " + operand2 + " = " + result;
2626
}
2727
}

exercises/concept/calculator-conundrum/src/test/java/CalculatorConundrumTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void divisionWithLargeOperands() {
5353
@DisplayName("The calculate method throws IllegalOperationException when passing invalid operation")
5454
public void throwExceptionForUnknownOperation() {
5555
String invalidOperation = "**";
56-
String expectedMessage = String.format("Operation '%s' does not exist", invalidOperation);
56+
String expectedMessage = "Operation '" + invalidOperation + "' does not exist";
5757
assertThatExceptionOfType(IllegalOperationException.class)
5858
.isThrownBy(() -> new CalculatorConundrum().calculate(3, 78, invalidOperation))
5959
.withMessage(expectedMessage);

exercises/concept/captains-log/.meta/src/reference/java/CaptainsLog.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ char randomPlanetClass() {
1818
String randomShipRegistryNumber() {
1919
var start = 1000;
2020
var end = 10000;
21-
return String.format("NCC-%d", start + random.nextInt(end - start));
21+
22+
23+
return "NCC-" + String.valueOf(start + random.nextInt(end - start));
2224
}
2325

2426
double randomStardate() {

exercises/concept/logs-logs-logs/.meta/src/reference/java/LogLine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public LogLevel getLogLevel() {
2121
}
2222

2323
public String getOutputForShortLog() {
24-
return String.format("%d:%s", this.level.getEncodedLevel(), this.message);
24+
return String.valueOf(this.level.getEncodedLevel()) + ":" + this.message;
2525
}
2626
}

0 commit comments

Comments
 (0)