Quando o Emmy erra pouco

Quem diria que depois de todas as trapalhadas nas indicações, o Emmy do último domingo, 18 de setembro, entrou para a História como um dos mais justos dos últimos tempos. Na expectativa de uma…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Command Pattern in Java

Command Design is one of the Behavioral design patterns.

The Command Pattern is useful when:

Command design pattern is a behavioral design pattern. We use it to encapsulate all the information required to trigger an event. Some of the main uses of Command pattern are:

ASDW used to control the car.

Suppose I creating this car game. I want players to configure button actions. We can give this freedom of choice, via Command Pattern.

Button.java

GameCharacter.java

2. Now we have to create Commands based on things, that invokee can perform.

ICommand.java

MoveDownCommand.java

Note:

MoveUpCommand.java

3. The Driver class to test this.

Found it Interesting?
Please show your support by 👏. To read the complete series, click below.

Disclaimer:
I myself, has just started learning, design patterns. If you find any issues please feel free to post them in the comments section below. Thank you for reading so far 😄

Add a comment

Related posts:

Jasa Pembuatan Greenhouse di Aceh Barat Daya

Green House adalah sebuah bangunan kontruksi yang berfungsi untuk menghindari dan memanipulasi kondisi lingkungan agar tercipta kondisi lingkungan yang dikehendaki dalam pemeliharaan tanaman. Dengan…

We May Owe Our Existence to Saturn

Saturn is my favorite planet. And I’m not alone — Neil deGrasse Tyson and Stephen Hawking have also admitted to favoring Saturn over the others (except maybe Earth). But whether or not you believe it…

Do You Know About the Advantages of Low Foaming Nonionic Surfactants?

Detergent is a very broad term; it includes various kinds of industrial detergents and commercial detergents. Commercial detergent is the most common type of detergent for consumers. Besides the…