https://github.com/sarahabuirmeileh/desginpatterns
This project demonstrates the most popular Design Patterns using Java.
https://github.com/sarahabuirmeileh/desginpatterns
Last synced: 8 months ago
JSON representation
This project demonstrates the most popular Design Patterns using Java.
- Host: GitHub
- URL: https://github.com/sarahabuirmeileh/desginpatterns
- Owner: SarahAbuirmeileh
- Created: 2024-07-22T18:18:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-27T15:44:10.000Z (about 1 year ago)
- Last Synced: 2025-01-16T01:15:01.667Z (9 months ago)
- Language: Java
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Singleton Design Pattern Project 👩🏻💻🎯
## Project Overview 📌
This project demonstrates the Singleton Design Pattern in Java. The Singleton Design Pattern ensures that a class has only one instance and provides a global point of access to it.## File Descriptions 📑
### SystemClock.java 📁
This class implements the Singleton Design Pattern for a system clock. It ensures that only one instance of SystemClock exists and provides a method to get the current system time in milliseconds.
### Methods: ⚙️
* getInstance(): Returns the single instance of SystemClock. If the instance does not exist, it creates one.
* currentTimeMillis(): Returns the current system time in milliseconds.
### SingltonDesginPattern.java 📁
This is the main class that demonstrates the usage of the SystemClock singleton. It verifies that only one instance of SystemClock is created and used throughout the application.
### Methods: ⚙️
main(String[] args): The entry point of the application. It creates two references to SystemClock using getInstance() and prints the current system time. It also checks if both references point to the same instance.