Skip to content

YuriiJavaDev/JavaBasics_Task_345_V0.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interactive Drawing: Behavior Abstraction (JavaBasics_Task_345_V0.1)

📖 Description

In drawing applications, the ability to process various shapes through a unified mechanism is a core requirement. This project implements a Universal Drawing Contract using the Drawable interface. By separating the "what to do" (the draw() method) from the "how to do it" (the specific shape logic), the application achieves high flexibility. Any new shape created in the future can be integrated into the existing drawing logic simply by implementing the Drawable interface.

📋 Requirements Compliance

  • Contract Definition: Established the Drawable interface as a standard for all renderable objects.
  • Interface Implementation: Realized the draw() method within the Circle class.
  • Abstract-to-Concrete Mapping: Demonstrated how an interface variable acts as a "tool" that can hold any compliant object.
  • Behavioral Verification: Confirmed that invoking the interface method triggers the specific implementation logic.

🚀 Architectural Stack

  • Java 8+ (Interfaces, Polymorphism, Behavioral Design)

🏗️ Implementation Details

  • Drawable: The interface defining the mandatory draw() method.
  • Circle: A concrete shape that fulfills the drawing contract.
  • DrawingLauncherApp: The entry point for demonstrating the universal drawing tool.

📋 Expected result

Drawing a circle.

💻 Code Example

Project Structure:

JavaBasics_Task_345/
├── src/
│   └── com/yurii/pavlenko/
│                 ├── app/
│                 │   └── DrawingLauncherApp.java
│                 └── graphics/
│                     ├── contracts/
│                     │   └── Drawable.java
│                     └── primitives/
│                         └── Circle.java
├── LICENSE
├── TASK.md
├── THEORY.md
└── README.md

Code

package com.yurii.pavlenko.app;

import com.yurii.pavlenko.graphics.contracts.Drawable;
import com.yurii.pavlenko.graphics.primitives.Circle;

public class DrawingLauncherApp {

    public static void main(String[] args) {

        Drawable tool = new Circle();

        tool.draw();
    }
}
package com.yurii.pavlenko.graphics.contracts;

public interface Drawable {
    void draw();
}
package com.yurii.pavlenko.graphics.primitives;

import com.yurii.pavlenko.graphics.contracts.Drawable;

public class Circle implements Drawable {

    @Override
    public void draw() {
        System.out.println("Drawing a circle.");
    }
}

⚖️ 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 tutorial project. JavaBasics_Task_345_V0.1 Graphics Engine: defining the Drawable interface to establish a universal drawing contract for geometric primitives. 190426_1339

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages