title: Returning Void For A Factory Method Pattern
body: <p>I am currently completing an assignment for class and one of the questions wants me to reconstruct some of the sample code given to me.</p>
  
  <p>without being too precise, they have an abstract class with several different subclasses and each different subclass is assigned a weapon depending on what kind of subclass it is.</p>
  
  <p>e.g.</p>
  
  <pre><code>if (this.getClass().getSimpleName().equals("FighterJet")) {
      this.weapon = new GuidedMissileSystem();
      System.out.println("FighterJet " + id + " equipped with " + weapon.getClass().getSimpleName());
  } 
  else if (this.getClass().getSimpleName().equals("AttackHelicopter")) {
      this.weapon = new GrenadeLauncher();
      System.out.println("AttackHelicopter " + id + " equipped with " + weapon.getClass().getSimpleName());
  ...
  </code></pre>
  
  <p>it then prints a string to the console which has the name of the subclass and the weapon.</p>
  
  <p>in the abstract superclass it has a series of if statements to check what subclass it is and to assign the proper weapon to it and print the proper string.</p>
  
  <p>they suggested looking at a design pattern and i opted for the 'factory method', however, since it's printing a string that has the name of the subclass in it, i decided to not return anything in this method and just assign the weapon through this syntax:</p>
  
  <pre><code>    this.weapon = //whatever weapon
  </code></pre>
  
  <p>and returning void.</p>
  
  <p>Is this still considered the factory method? I suspect it isn't.</p>
  
  <p>Thanks!</p>