A robot soccer weaving

This is a regular exercise of the course Magas szintű programozási nyelvek 2, in the robot soccer team called GoldenTeamFC-0.0.4sumkick-project.zip, where itself the Maven's pom.xml file itself weaves the AspectJ aspect into the code of the team. In the case of GoldenTeam we need the average of the powers of all performed passes and the average of the angles of the passes. In order to compute these quantities we would need to process the all kick commands. It is a crosscutting concept and it can be implemented easily with AspectJ.

 public aspect
        NagytesoKick { private long szamlalo = 1; private long eroSum = 0;
        private double szogSum = 0.0; before(int ero, double szog): call(*
        kick(int, double)) && !cflow(adviceexecution()) &&
        args(ero, szog) { System.out.println("Nagyteso> " +
        thisJoinPointStaticPart.getSourceLocation());
        System.out.println("Nagyteso> " +
        thisJoinPointStaticPart.getKind()); System.out.println("Nagyteso> "
        + thisJoinPointStaticPart.getSignature()); ++szamlalo; eroSum += ero;
        szogSum += szog; System.out.println("Nagyteso> " + (szamlalo-1));
        System.out.println("Nagyteso> " + (double)eroSum / szamlalo);
        System.out.println("Nagyteso> " + szogSum / szamlalo); } }
        

If the reader has any question about this aspect please comment on the blog post: http://progpater.blog.hu/2011/12/04/a_nagytestver_beleszott_egy_aspektust_a_csapatomba.

Example 8.2. Try this AspectJ aspect yourself

All you have to do is to download the GoldenTeam. Then let's build it and run it and see:

2519280 [GoldenFC3 Player # 6] INFO
          hu.fersml.magyarfc.Jatekos - LATOM A MASIK KAPUT 6 tavolsaga = 21.5
          iranya = 22.0 Nagyteso> Jatekos.java:512 Nagyteso> method-call
          Nagyteso> void atan.model.ActionsPlayer.kick(int, double)
          Nagyteso> 53 Nagyteso> 45.648148148148145 Nagyteso>
          -1.3333333333333333