title: java interface - object oriented related
body: <p>Hi friends I am new in java and trying some example but not getting expected output.</p>
  
  <p>I am applying here dependency injection without spring but not getting expected output.</p>
  
  <p><code>BaseballCoach</code> is dependent on <code>FortuneServices</code> for daily fortune and here I am trying to inject <code>FortuneServices</code> in a <code>BaseballCoach</code> constructor...</p>
  
  <p>Here I am expecting out put "<strong>today is ur lucky day</strong>";
  and please tell me where I am doing wrong with some simple language    theoretical explanation...</p>
  
  <p>Thanks in advance</p>
  
  <p>some one help is more valuable...</p>
  
  <p>-->this is the main class which takes </p>
  
  <pre><code>        public class DiMain 
          {
              public static void main(String[] args) 
              {
                  HappyFortune hf = new HappyFortune();
                  BaseballCoach bs = new BaseballCoach(hf);//this is constructor which act as  dependency. 
  
                  bs.getDailyFortune();
              }
          }
  </code></pre>
  
  <p>-->another class which have parameterize constructor </p>
  
  <pre><code>    public class BaseballCoach
      {
          private FortuneServices fortunes;
  
          public BaseballCoach(FortuneServices thefortuneservices)
          {
              fortunes = thefortuneservices;
          }
  
  
          public String getDailyFortune()
          {
              return fortunes.getFortune();
  
          }
      }
  </code></pre>
  
  <p>-->this is Interface class</p>
  
  <pre><code>    public interface FortuneServices 
      {
          public String getFortune();
      }
  </code></pre>
  
  <p>-->&amp; this class implement the interface</p>
  
  <pre><code>   public class HappyFortune implements FortuneServices 
     {
          public String getFortune()
          {
              return "today is ur lucky day";
          }
      }        
  </code></pre>