Class AddShapeCommand

java.lang.Object
com.example.renderer.command.AddShapeCommand
All Implemented Interfaces:
Command

public class AddShapeCommand extends Object implements Command
Command implementation for adding a shape to a shape list. Supports undo operation by removing the added shape.
  • Constructor Details

    • AddShapeCommand

      public AddShapeCommand(List<Shape> shapes, Shape shape)
      创建添加图形命令实例
      Parameters:
      shapes - 目标图形列表(非null)
      shape - 要添加的图形(非null)
      Throws:
      NullPointerException - 如果参数为null
  • Method Details

    • execute

      public void execute()
      Description copied from interface: Command
      Executes the command operation. Implementations should perform the actual operation here.
      Specified by:
      execute in interface Command
    • undo

      public void undo()
      Description copied from interface: Command
      Undoes the command operation. Implementations should revert the execute() operation here.
      Specified by:
      undo in interface Command