Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Train Dispatch System
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johanne Fixdal
Train Dispatch System
Commits
9efe63b7
Commit
9efe63b7
authored
1 year ago
by
Johanne Fixdal
Browse files
Options
Downloads
Patches
Plain Diff
Removed ClockUpdate as an own Commands class
parent
03ee14c7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/ntnu/stud/commands/ClockUpdate.java
+0
-48
0 additions, 48 deletions
src/main/java/edu/ntnu/stud/commands/ClockUpdate.java
with
0 additions
and
48 deletions
src/main/java/edu/ntnu/stud/commands/ClockUpdate.java
deleted
100644 → 0
+
0
−
48
View file @
03ee14c7
/**package edu.ntnu.stud.commands;
import edu.ntnu.stud.TrainDeparture;
import edu.ntnu.stud.TrainDispatchApp;
import edu.ntnu.stud.commands.Command;
import java.time.LocalTime;
import java.util.Calendar;
import java.util.Scanner;
public class ClockUpdate extends Command {
public ClockUpdate() {
super("Update clock", "Update the clock by entering new time");
}
@Override
public boolean run(TrainDispatchApp app) {
Scanner sc = new Scanner(System.in);
System.out.println("Type in new time on format hh:mm: ");
String clockInput = sc.nextLine();
LocalTime newClock = parseInput(clockInput);
if (newClock != null) {
TrainDeparture.setClock(newClock);
System.out.println("The clock is now updated to " + TrainDeparture.getClock());
} else {
System.out.println("Invalid input format. Please try again (hh:mm) ");
}
return false;
}
private LocalTime parseInput(String clockInput) {
try {
String[] timeParts = clockInput.split(":");
if (timeParts.length == 2) {
int hours = Integer.parseInt(timeParts[0]);
int minutes = Integer.parseInt(timeParts[1]);
if (hours >= 0 && hours < 24 && minutes >= 0 && minutes < 60) {
return LocalTime.of(hours, minutes);
}
}
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
// Handle parsing errors here
}
return null;
}
}
*/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment