-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java-Nerdery-ChallengeV2/Luis-Moroco #6
Open
luismoroco
wants to merge
16
commits into
ravnhq:master
Choose a base branch
from
luismoroco:develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
74ea96f
feat: complete readableTime function
luismoroco f7530a9
feat: complete circularArray function
luismoroco a054beb
feat: complete ownPower function
luismoroco ae739e0
feat: complete digitSum function
luismoroco 7eaf057
feat: complete decrypt function
luismoroco 5c32161
feat: complete encrypt function
luismoroco b3287b7
feat: complete calculateWinningHand function
luismoroco 185f59d
feat: complete calculateCost function
luismoroco 9a97f8e
feat: complete extra challenge weatherStations function
luismoroco 4598a14
refactor: remove enums. Remove unnecessary abstract classes. Remove u…
luismoroco 0af948a
feat: add ZonedDateTime for get day of the week in extra challenge
luismoroco 13b926f
chore: add data file to gitignore
luismoroco bd541fa
refactor: improve Variable.properties initialization using EXTREMES v…
luismoroco 1b08c4e
refactor: use Objects.isnull instead of direct comparation
luismoroco 085d8a3
feat: add Variable.getAverage function for avoid undetermined divisio…
luismoroco 577a65a
refactor: remove AggregatedMeteorologyReport class. Move processing l…
luismoroco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,8 @@ build/ | |
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
.DS_Store | ||
|
||
### Files | ||
|
||
*.json |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import com.fasterxml.jackson.core.JsonFactory; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import meteorology.model.Weather; | ||
import meteorology.MeteorologyReport; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class ExtraChallenges { | ||
final static String FILE_PATH = "weather.json"; | ||
|
||
public static void main(String[] args) { | ||
var FILE = new File(FILE_PATH); | ||
var factory = new JsonFactory(); | ||
var mapper = new ObjectMapper(factory); | ||
|
||
var meteorologyReport = new MeteorologyReport(); | ||
|
||
try { | ||
var parser = factory.createParser(FILE); | ||
if (parser.nextToken() == JsonToken.START_ARRAY) { | ||
while (parser.nextToken() != JsonToken.END_ARRAY) { | ||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we parsing the list like this? |
||
var weather = mapper.readValue(parser, Weather.class); | ||
if (!weather.verifyFields()) { | ||
continue; | ||
} | ||
|
||
meteorologyReport.process(weather); | ||
} | ||
} | ||
|
||
meteorologyReport.show(); | ||
} catch (IOException | IllegalAccessException | NoSuchFieldException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package meteorology; | ||
|
||
import meteorology.model.Report; | ||
import meteorology.model.Weather; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class MeteorologyReport { | ||
protected Map<String, Report> dailyReports = new HashMap<>(); | ||
protected Report overview = new Report(); | ||
|
||
public void process(Weather weather) throws NoSuchFieldException, IllegalAccessException { | ||
this.overview.process(weather); | ||
|
||
var report = this.dailyReports.get(weather.getDate()); | ||
if (Objects.isNull(report)) { | ||
report = new Report(); | ||
report.process(weather); | ||
|
||
this.dailyReports.put(weather.getDate(), report); | ||
return; | ||
} | ||
|
||
report.process(weather); | ||
} | ||
|
||
public void show() { | ||
for (var report : this.dailyReports.entrySet()) { | ||
System.out.println(report.getKey()); | ||
report.getValue().show(); | ||
} | ||
|
||
System.out.println("OVERVIEW"); | ||
this.overview.show(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package meteorology.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class Location { | ||
public Double lon; | ||
public Double lat; | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
pow
(ormodPow
if using modulo-based solution)