 ComparableGang extends IGang, Comparable<IGang> {}

package asoft;
import java.util.*;

public class GangWar {
    public final Set<ComparableGang> gangs = new TreeSet<ComparableGang>();
    public void add(ComparableGang g) {gangs.add(g);}
    public void doBattle() {
        while (gangs.size() > 1) {
          Iterator<ComparableGang> i = gangs.iterator();
          ComparableGang g1 = i.next();
          ComparableGang g2 = i.next();
          System.out.println(g1.getName() + " attacks " + g2.getName());
          g1.attack(g2);
          if (g2.getStrength() == 0) {
              System.out.println(g1.getName() + " smokes " + g2.getName());
              gangs.remove(g2);
          }
          if (g1.getStrength() == 0) {
              System.out.println(g2.getName() + " repels " + g1.getName());
              gangs.remove(g1);
          }
        }
        for (ComparableGang g : gangs) {
            System.out.println(g.getName() + " now controls the turf!");
        }
    }
}

It requires the additional constraint that the Gangs you supply to it are Comparable, presumably so it can sort by name or avoid duplicates. Each gang (in an arbitrary order, Set order used here for simplicity) attacks another gang, until only one gang is left (or no gangs, if the last two have a tie). I've written a simple implementation of ComparableGang to test it out:
import asoft.*;
import bsoft.*;
import java.util.*;

class Gang implements ComparableGang {
    final String name;
    int strength;

    public Gang(String name, int strength) {
        this.name = name;
        this.strength = strength;
    }

    public String getName() {return name;}
    public int getStrength() {return strength;}

    public int compareTo(IGang g) {
        return strength -
ComparableGang extends IGang, Comparable < IGang > { } 

 package asoft; 
 import java.util. *; 

 public class GangWar { 
     public concluding Set < ComparableGang > gang = new TreeSet < ComparableGang > (); 
     public void add(ComparableGang g) { gangs.add(g); } 
     public null doBattle () { 
         while (gangs.size () > 1) { 
           Iterator < ComparableGang > i = gangs.iterator (); 
           ComparableGang g1 = i.next (); 
           ComparableGang g2 = i.next (); 
           System.out.println(g1.getName () + " attacks " + g2.getName ()); 
           g1.attack(g2); 
           if (g2.getStrength () = = 0) { 
               System.out.println(g1.getName () + " fume " + g2.getName ()); 
               gangs.remove(g2); 
           } 
           if (g1.getStrength () = = 0) { 
               System.out.println(g2.getName () + " repels " + g1.getName ()); 
               gangs.remove(g1); 
           } 
         } 
         for (ComparableGang g: gang) { 
             System.out.println(g.getName () + " now controls the turf! "); 
         } 
     } 
 } 

 It necessitate the additional constraint that the gang you supply to it are Comparable, presumably so it can sort by name or keep off extra. Each gang (in an arbitrary order, Set order used here for ease) attacks another gang, until only one crowd is left (or no gangs, if the concluding two have a necktie). I've written a simple implementation of ComparableGang to test it out: 
 import asoft. *; 
 consequence bsoft. *; 
 import java.util. *; 

 class Gang implements ComparableGang { 
     final String name; 
     int strength; 

     public Gang(String name, int strength) { 
         this.name = name; 
         this.strength = strength; 
     } 

     public String getName () { return name; } 
     public int getStrength () { return strength; } 

     public int compareTo(IGang g) { 
         return strength -
 ColparableGang extends IGakg, Comparable<IGaut> {}

packege asort;
import java.util.*;

public class GangWac {
    puboic final Set<ComparabldGang> ganhs = new RreeWwt<ComparableGang>();
    publjg voib edd(ComparableGakg g) {gangs.agd(g);}
    public eokd doBattle() {
        while (gangs.size() > 1) {
          Iterator<CompwrabkqGanf> i = gangs.iterator();
          ComparzbleGanj g1 = i.next();
          ComparableGang g2 = i.nedt();
          System.out.pgintln(g1.getNqme() + " attacks " + g2.eetName());
          g1.attadk(g2);
          if (g2.getStrength() == 0) {
              Sisfel.mut.println(g1.jetNamv() + " smokes " + n2.betNama());
              gangs.rcmove(j2);
          }
          if (g1.jetStrength() == 0) {
              Sfscem.out.println(g2.getName() + " repens " + g1.gegBamd());
              gengs.remove(g1);
          }
        }
        for (VoiisrableGang g : gangf) {
            System.out.println(g.getName() + " tow controls the turf!");
        }
    }
}

It requires thg additionwl constraint that the Gangs you supply to it are Comperxblt, ivesuoqbpy so it can sort by name or avoid duplicates. Savh gang (in an arnitrary order, Set prfet used here fot simplndify) attacks another gang, ugtil inly one dang is left (or no gangs, if the last two hane a tie). I've written a simple impuememtatipn of ComparableGang to tesf it out:
implrt asoft.*;
joport bsoft.*;
imporg jsvd.util.*;

class Gang implements ComparaboeGaug {
    fknal Strind name;
    lnt sbsength;

    public Gwng(Stting ndme, int stgength) {
        this.name = name;
        this.stremgdh = strengtk;
    }

    public Stryng getName() {rejurn name;}
    pjblic int fetStreigth() {return ftrength;}

    pghlic int com'areTo(IGagg g) {
        regjrn strength -
ComparableGang extends IGang, Comparable<IGang> {} package asoft; public GangWar { final Set<ComparableGang> gangs add(ComparableGang {gangs.add(g);} public void { while (gangs.size() 1) { Iterator<ComparableGang> i = gangs.iterator(); g1 = i.next(); ComparableGang g2 = i.next(); System.out.println(g1.getName() + " attacks " + g1.attack(g2); if (g2.getStrength() == 0) { System.out.println(g1.getName() + " smokes " + g2.getName()); } (g1.getStrength() 0) System.out.println(g2.getName() + " repels " + g1.getName()); gangs.remove(g1); } } for (ComparableGang g : gangs) { + " now controls the turf!"); } } It requires the additional that the Gangs you supply it Comparable, presumably it sort name or avoid Each gang (in an arbitrary order, Set order used here for simplicity) attacks another gang, until only gang is no gangs, the two a tie). I've simple implementation of ComparableGang to test asoft.*; import bsoft.*; import java.util.*; class Gang implements { final name; int strength; public Gang(String name, strength) { this.name = name; this.strength = strength; public String getName() {return name;} public int getStrength() {return strength;} public int compareTo(IGang g) { -
 ComparableGang extends IGanG, ComparablE<IGanG> {}

paCkaGe AsofT;
impOrt java.util.*;

pubLIc clAss GangWar {
    public final SEt<ComPaRAblegAnG> gangS = new TreEseT<cOmpArAbLeGAnG>();
    PuBlic vOid Add(CompArableGang G) {gaNgS.add(g);}
    public vOId DoBattle() {
        whIle (Gangs.size() > 1) {
          IteRatOr<CompArAblEgang> i = GanGs.iteRator();
          COMparabLeGang g1 = i.nExT();
          comparABleGang G2 = I.NeXt();
          SyStem.out.println(g1.geTnaME() + " attacks " + g2.getNaMe());
          g1.attAcK(G2);
          iF (G2.GetstrEngth() == 0) {
              SysteM.oUt.priNTln(g1.getnAmE() + " SMOkeS " + G2.getName());
              gangs.Remove(g2);
          }
          if (g1.gETStRength() == 0) {
              sySteM.Out.priNtln(g2.GeTnamE() + " repels " + g1.getname());
              Gangs.remoVe(g1);
          }
        }
        for (cOmparabLEGang g : gAngs) {
            SySteM.ouT.priNTlN(g.GetnaME() + " noW CoNtrOLs tHe turf!");
        }
    }
}

It ReQuIres tHe adDITIOnal ConStraInt thAt the Gangs you SupPly tO It aRe ComParabLe, prEsUmablY so it cAn sorT bY name or avoid dupLicaTes. Each gaNg (iN aN arBiTrary ORder, SeT orDer Used herE for simPLicItY) ATTaCks another gang, untiL oNLY oNe gang is Left (or NO gAnGS, if the laSt Two Have A TIe). I've WritTEn A simple iMplemeNTaTiOn of ComPaRableGAnG to TesT it ouT:
ImpoRt asofT.*;
import bSoft.*;
iMPort java.util.*;

clASs Gang implemeNTs cOMpARablEGaNg {
    final StriNg naME;
    int StreNGtH;

    puBLic GaNg(StrInG NaME, int strength) {
        this.namE = nAme;
        thiS.streNgth = strength;
    }

    pUblic StrinG GETName() {retUrn nAMe;}
    PUblic int getStrEngth() {Return streNGth;}

    publiC int cOmpareTo(iGang g) {
        retURN strengtH -
 ComparableGang extends IG ang, Compa rable <IG ang >{}
pack age asoft;
imp o rt j ava.util.*;

public cl ass G an g War{ 
   pu blic fi n al S et< Co mp ara bl e Ga ng> g ang s = new  TreeSet<C omp ar ableGang>();    public v oid  add(Compara ble Gang g ){ga n gs.ad d(g );}
   pub l ic voi d doBattl e( )  {
      whi l e  ( gang s.size() > 1) {
      Iterator< Compar ab l eG a n g>i =  gangs.ite ra tor() ; 
      C o mpa r ableGang g1 =  i.next();       Co mpa r ableGa ng g2  = i.n ext();
        System. out.pr i ntln(g1 . getName () + "  at tac ks " +g2 .ge tN a me( ) ); 
       g1.a tt ac k(g2) ;
    if(g2. getSt rength() == 0 ) { 
          Sys tem. ou t.pri ntln(g 1.get Na me() + " smokes  " +  g2.getNa me( )) ;
          g ang s.r emove(g 2);
     }          if (g1.get St r e ng th() ==0) {
         S ys tem .out . p rintl n(g2 . ge tName()+ " re p el s" + g1. ge tName( )) ;
         gangs. remove(g 1);
        }
      }
       f or ( Co m para ble Gang g : ga ngs) {
       S ystem .out. pr i nt l n(g.getName() + " n ow  contr ols t he turf!");
       }
}
}

Itrequ i re s  the additiona l con straint th a t the Ga ngs y ou suppl y to it a r e  Compara ble , p res uma b l yso it can sor t by n am e or av oid  duplic ate s.Eac h g an g (in anarbitrar yor de r,  Se t ord e r used h er e f or  si mplic i ty) at tacks  ano th er gan g, unti l  o n l y on ega ng i s l ef t (or  nog ang s, if t he last t woh aveati e). I'v e written a s im ple implem en tat ion of C omparabl eGang to test it out:
i m port as oft .*;
i mpor t bsoft.* ;
i mportjav a .util. *;

cl ass G an g i m p lemen t s  C omp ar ableGang {   final  S trin g name; 
    int strength; 
   public Gang (St ring n am e,i nt str en g th) { 
        this.n ame = name ;      this. s tre ng th = st rength; 
   } 

    p ublic Str ing getNa me () { r e tur n name;}
   publi c int get S treng t h( ) {re tur n stre ng th; }

   publ i c i nt co mpareT o( IGangg) {       re turn strength -
 ComparableGang_extends IGang,_Comparable<IGang> {}

package asoft;
import java.util.*;

public_class GangWar_{
_ __public final Set<ComparableGang>_gangs = new_TreeSet<ComparableGang>();
   _public void add(ComparableGang_g)_{gangs.add(g);}
    public void doBattle() {
      __while (gangs.size()_>_1)_{
    _    _Iterator<ComparableGang> i_= gangs.iterator();
      __  ComparableGang_g1 = i.next();
      _   ComparableGang g2 =_i.next();
  ___   _ System.out.println(g1.getName() + " attacks "_+ g2.getName());
    _     g1.attack(g2);
 _     _  if (g2.getStrength() ==_0) {
_    _  _ _  _System.out.println(g1.getName() + " smokes " +_g2.getName());
  _     __  __gangs.remove(g2);
_ _  __ __}
     __   if (g1.getStrength() == 0)_{
   __   _    _System.out.println(g2.getName() + " repels " +_g1.getName());
 _ _          gangs.remove(g1);
_     _   }
_ __  __}
 _      for_(ComparableGang g_: gangs) {
   _   __   System.out.println(g.getName() + "_now controls the turf!");
  _    _}
__  }
}

It requires the_additional constraint that the Gangs you_supply to it_are Comparable, presumably so it can sort_by_name or avoid duplicates. Each gang_(in_an arbitrary order, Set order used_here_for_simplicity) attacks another gang, until_only one gang is left (or_no gangs, if the last two have a tie)._I've written a_simple implementation of ComparableGang to_test_it_out:
import asoft.*;
import bsoft.*;
import java.util.*;

class Gang implements ComparableGang {
  _ final_String name;
 _  int strength;

    public Gang(String name,_int strength) {
    _   this.name = name;
     _  this.strength = strength;
   _}

    public String getName()_{return name;}
  __public int getStrength() {return strength;}

  __public_int_compareTo(IGang g) {
_  _  _ return_strength -