Delphi combinatorics app

I have created a component that is useful in math for Combinatorics! If you don’t know about them you can loot at here for more information about; below you can see a video of the component in action! I made this:

This is the relevant code:

uses
 System.Math, System.SysUtils, Combinatorio, System.Classes;

type

 TCombinazioni = class(TInterfacedObject, ICombinatorio)
  private
   n, k: integer;
   ripetizione: boolean;
   function fattoriale(const x: integer): integer;
  public
   constructor Create(const n, k: integer; const ripetizione: boolean);
   function getSoluzioni(): integer;
   function getFormula(): string;
 end;

 TDisposizioni = class(TInterfacedObject, ICombinatorio)
  private
   n, k: integer;
   ripetizione: boolean;
   function fattoriale(const x: integer): integer;
  public
   constructor Create(const n, k: integer; const ripetizione: boolean);
   function getSoluzioni(): integer;
   function getFormula(): string;
 end;

 TPermutazioni = class(TInterfacedObject, ICombinatorio)
  private
   n: integer;
   k: string;
   ripetizione: boolean;
   function fattoriale(const x: integer): integer;
  public
   constructor Create(const n: integer; const k: string; ripetizione: boolean);
   function getSoluzioni(): integer;
   function getFormula(): string;
 end;

They implement interfaces so they are reference counted and you don’t need to call the Free! Very cool isn’t it? The main interface in particular is the following:

unit Combinatorio;

interface

type
 ICombinatorio = interface
  function getSoluzioni(): integer;
  function getFormula(): string;
 end;

implementation

end.

If you want to have the entire source code or the component, just leave a comment in the video! Happy coding!

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.