CodeLab
This CodeLab exercise is designed to help you practice the concepts you have learned in the Java Deep Dive I module on day-1. You will be working on a series of tasks that involve Java Streams, Java Time API, and Lambdas. You will also practice using Git and Github. Make an effort to use Git on the command line as much as possible (Git Bash / Terminal) to get more comfortable with it. Check Git help in the bottom of this page for more information.
- Team up in pairs so you can learn from each other.
- Remember to tick your attendance in Moodle
- Fork Flight data Repo into your own Github account. The Flight data Repo is a simple application that reads a CSV file with flight data and calculates the total flight time for each airline. If you don’t want to fork the repo, then download a ZIP file of the repo and extract it locally.
- Open the project in IntelliJ IDEA
- Make sure that the project builds and runs without errors. If you have issues, make sure that all Maven dependencies are downloaded and that the project SDK is set to Java 17.
- Run the application (find the Main class in
FlightReader
) and see how it works - Look at the code and understand how it works. How does the duration of the flights get calculated and more? You might want to know more about the Lombok library and how it is used in the code to simplify getters, setters etc.
- Look at the
json
file and discuss the structure of the data with your team - Make sure that the data in the
json
file correlates with the data printed in the console - Find the unit-test and run it.
- See if you can understand the test and what it is testing. Could it be improved?
Inspiration for first round tasks:
- Add a new feature (e.g. calculate the total flight time for a specifc airline. For example, calculate the total flight time for all flights operated by Lufthansa)
- Create a branch off the
main
branch for each task. Call it something likeround-1
- Work on the tasks and help each other.
- Merge the
round-1
branch into the main branch:- On the
round-1
branch: add the changes to the staging area, then you commit the changes - Checkout the main branch and merge the
round-1
branch into it.
- On the
- Remove the
round-1
branch - Add, commit, and push the changes from
main
to the remote repository - Check that the remote repository is up to date
- Identify the next tasks (get inspiration from the list below)
- Repeat steps 5-7 for the next tasks
- Add a new feature (e.g. calculate the average flight time for a specific airline. For example, calculate the average flight time for all flights operated by Lufthansa)
- Add a new feature (make a list of flights that are operated between two specific airports. For example, all flights between Fukuoka and Haneda Airport)
- Add a new feature (make a list of flights that leaves before a specific time in the day/night. For example, all flights that leave before 01:00)
- Add a new feature (calculate the average flight time for each airline)
- Add a new feature (make a list of all flights sorted by arrival time)
- Add a new feature (calculate the total flight time for each airline)
- Add a new feature (make a list of all flights sorted by duration)
- Refactor the code where needed. Make sure that the code is clean and easy to read.
git branch round-1
git switch round-1
git add .
git commit -m "Add feature to calculate the total flight time for a specific airline"
git switch main
git merge round-1
git branch -d round-1
git push