Skip to content

YuriiJavaDev/JavaBasics_Task_17

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Flight Tracker (JavaBasics_Task_17)

📌 Description

This project demonstrates string concatenation in Java by combining numeric flight data with destination text to create a complete status message.

🚀 Task Requirements

  • Create an int variable named flight for the flight number.
  • Create a String variable named city for the destination.
  • Combine them using the + operator or the String.format() method into a single string.
  • Output the final result to the console.

🛠 Technical Stack

  • Language: Java 23 (Current version)
  • IDE: IntelliJ IDEA
  • Concepts: String Concatenation (int to String).

⌨️ Practical Implementation

This task could be solved via simple concatenation. However, following the principles of Сlean Сode, the String.format() method was used to create a clear flight message template.

Why this approach?

  1. Separation of Concerns: The template "Flight %d to %s" is separated from the data, making the code easier to maintain.
  2. Explicit Formatting: Using %d (for integers) and %s (for strings) clearly defines the expected data types.
  3. Readability: It avoids the "spaghetti code" of multiple + operators and quotes.

📋 Example Output

Flight 747 to Eilat

💻 Code Example

package com.yurii.pavlenko;

/**
 * Task 17: Flight tracking program.
 * Demonstrates advanced string formatting using templates.
 */
public class Task_17_App {
    public static void main(String[] args) {
        // 1. Create a variable for the flight number (primitive type)
        int flight = 747;

        // 2. Create a variable for the destination city (object type)
        String city = "Eilat";

        // 3. Format the message using String.format (Clean Code approach)
        // %d is a placeholder for the integer (flight)
        // %s is a placeholder for the string (city)
        String flightInfo = String.format("Flight %d to %s", flight, city);

        // 4. Output the final formatted string to the console
        System.out.println(flightInfo);
    }
}

⚖️ License

This project is licensed under the MIT License.

Copyright (c) 2026 Yurii Pavlenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...

License: MIT

About

This is a learning project. JavaBasics_Task_17: Implementing a flight tracking message using data type conversion and using the String.format template. 170126_0929

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages