Skip to content

afa-farkhod/Temperature-Converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Temperature-Converter

Temperature Converter (Fahrenheit to Celsius and vise versa) application built on JavaFX. Also there is folder: "AFmaven-project-Test" which is the implementation of the same project with Maven building tool.

  • The main view of the app frame as following, which has the window for taking input temperature, and two buttons for Fahrenheit to Celsius and Celsius to Fahrenheit, and lastly output window. Project was built on the basis of MVC pattern (Model View Controller):

Image

  • This is the example screenshot when entering input temperature and press the button 'Fahrenheit to Celsius' to make conversion, then get the result on the output window:

Image

  • Last example showing the conversion from Celsius to Fahrenheit:

Image

  • The code follows the Model-View-Controller (MVC) design pattern, where the model (Model) handles the data and calculations, the view (UI) presents the user interface, and the controller (Controller) manages the interactions between the model and the view.
  • When the user enters a temperature and clicks on the corresponding conversion button, the controller updates the model and the UI, ensuring a separation of concerns and a clean code structure.
  • Controller class:
    • This class acts as a controller that handles the interaction between the UI (objUI) and the data model (objModel).
    • It implements two event listeners, FtoCListener and CtoFListener, which are responsible for performing temperature conversions and updating the UI accordingly.
    • In the FtoCListener and CtoFListener classes, the actionPerformed method is triggered when the corresponding conversion button is clicked.
    • Inside the actionPerformed method, the input temperature (inputTf) is retrieved from the UI using objUI.getInputTf().
    • The model's conversion methods (FtoC_Calculation and CtoF_Calculation) are called with the input temperature, and the calculated values are stored in the model.
    • The updated temperature values are then set in the UI using objUI.setOutputTf().
  • Main class:
    • This class serves as the entry point of the program.
    • It creates instances of the UI (objUI), model (objModel), and controller (objControl).
    • The UI is made visible by calling objUI.setVisible(true).
  • Model class:
    • This class represents the data model for the temperature converter.
    • It has two instance variables, FtoCvalue and CtoFvalue, to store the calculated temperature values.
    • The FtoC_Calculation method performs the Fahrenheit to Celsius conversion using the input temperature and stores the result in FtoCvalue.
    • The getFtoC_Calculation method returns the stored Celsius value.
    • The CtoF_Calculation method performs the Celsius to Fahrenheit conversion using the input temperature and stores the result in CtoFvalue.
    • The getCtoF_Calculation method returns the stored Fahrenheit value.

About

Temperature Converter (Fahrenheit to Celsius and vise versa) application built on JavaFX

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages