allstarcontest.zip

AllStarContest/.classpath

AllStarContest/.project

AllStarContest org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature

AllStarContest/.settings/org.eclipse.jdt.core.prefs

eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.8

AllStarContest/src/AllStar.java

AllStarContest/src/AllStar.java

public   class   AllStar  
{
     private   final   String  name ;
    
     public   AllStar ( final   String  sName )
     {
        name  =  sName ;
     }
    
     public   String  getName ()
     {
         return  name ;
     }
    
     public   Shot  shot ( Ball  ball )
     {
         return   ( Math . random ()   >=  ball . getMakeAbility ()   ?   new   Make ( ball . getShotCount (),  ball . getPointValue ())   :   new   Miss ( ball . getShotCount (),  ball . getPointValue ()));
     }
}
 

AllStarContest/src/AllStarContest.java

AllStarContest/src/AllStarContest.java

import  java . util . ArrayList ;
import  java . util . Iterator ;

public   class   AllStarContest  
{
     private   ArrayList < Ball >     balls     =   new   ArrayList < Ball > ( 10 );
     private   ArrayList < AllStar >  allStars  =   new   ArrayList < AllStar > ( 12 );
    
     public   static   void  main ( String []  args )  
     {
         new   AllStarContest (). allStarContest ();
     }

     public   AllStarContest ()
     {
        allStars . add ( new   AllStar ( "Eric Gordon" ));
        allStars . add ( new   AllStar ( "Stephen Curry" ));
        allStars . add ( new   AllStar ( "Marco Belinelli" ));
        allStars . add ( new   AllStar ( "Kevin Love" ));
        allStars . add ( new   AllStar ( "Paul Pierce" ));
        allStars . add ( new   AllStar ( "Dirk Nowitzki" ));
        allStars . add ( new   AllStar ( "Voshon Lenard" ));
        allStars . add ( new   AllStar ( "Peja Stojakovic" ));
        allStars . add ( new   AllStar ( "Jeff Hornacek" ));
        allStars . add ( new   AllStar ( "Glen Rice" ));
        allStars . add ( new   AllStar ( "Craig Hodges" ));
        allStars . add ( new   AllStar ( "Larry Bird" ));
        
         for   ( int  nthBall  =   0 ;  nthBall  <   10 ;   ++ nthBall )
         {
            balls . add ( new   Ball ( getPointValue ()));
         }
     }

     private   int  getPointValue ()
     {
         return   ( int )( Math . ceil ( Math . random ()   *   3.0f ));
     }

     public   void  allStarContest ()  
     {
         Shooter  allStarContestWinner  =   null ;

         Iterator < AllStar >  allstar  =  allStars . iterator ();
         while   ( allstar . hasNext ())
         {
             AllStar  currentAllStar  =  allstar . next ();
        
             Shooter  newShooter  =   new   Shooter ( currentAllStar . getName ());
            
             Iterator < Ball >  ball  =  balls . iterator ();
             while   ( ball . hasNext ())
             {
                 Ball  currentBall  =  ball . next ();
                
                 System . out . println ( "Passing "   +  currentBall  +   " to shooter - "   +  currentAllStar . getName ());
                
                 Shot  shot  =  currentAllStar . shot ( currentBall );
                newShooter . addShot ( shot );

                 System . out . println ( "It was "   +  shot );
             }
            
             if   ( allStarContestWinner  ==   null )
             {
                allStarContestWinner  =  newShooter ;
             }
             else
             {
                allStarContestWinner . rank ( newShooter );
             }
         }
        
         System . out . println ( allStarContestWinner );
        
         System . out . println ( allStarContestWinner . getAllStarContestWinner ());
     }
}

AllStarContest/src/Ball.java

AllStarContest/src/Ball.java

public   class   Ball  
{
     private   double  percentage  =   Math . random ();
     private   final   int  pointValue ;
     private   static   int  shots  =   0 ;
     private   int  shotCount  =   0 ;
    
     public   Ball ( final   int  nPointValue )
     {
         ++ shots ;
        
        shotCount  =  shots ;
        
        pointValue  =  nPointValue ;  
     }
    
     public   int  getShotCount  ()   {   return  shotCount ;    }
     public   int  getPointValue ()   {   return  pointValue ;   }
    
     public   double  getMakeAbility ()   {   return  percentage ;   }
    
     public   String  toString ()   {   return   "Ball #"   +  shotCount  +   " - worth "   +  pointValue  +   " point(s)" ;   }
}

AllStarContest/src/Make.java

AllStarContest/src/Make.java

public   class   Make   extends   Shot
{
     public   Make ( int  ballCount ,   int  ballValue )  
     {
         super ( ballCount ,  ballValue );
     }

     public   String  toString ()   {   return   "Made" ;   }
}

AllStarContest/src/Miss.java

AllStarContest/src/Miss.java

public   class   Miss   extends   Shot
{
     public   Miss ( int  ballCount ,   int  ballValue )  
     {
         super ( ballCount ,  ballValue );
     }

     public   String  toString ()   {   return   "Missed" ;   }
}

AllStarContest/src/Shooter.java

AllStarContest/src/Shooter.java

//TODO add any imports as needed

public   class   Shooter
{
     //TODO

     public   Shooter ( String  sName )
     {
         //TODO
     }
    
     public   void  addShot ( Shot  shot )
     {
         //TODO
     }

     public   void  rank ( Shooter  shooter )
     {
         //TODO
     }
    
     public   int  rankShooter ( Shooter  shooter )
     {
         return   0 ; //TODO
     }
    
    @ Override
     public   String  toString ()
     {
         //TODO
         return   "TODO" ;
     }

     public   String  getAllStarContestWinner ()
     {
         //TODO
         return   "AllStarContestWinner:TODO" ;
     }
}

AllStarContest/src/Shot.java

AllStarContest/src/Shot.java

public   abstract   class   Shot
{
     private   int  shotCount  =   0 ;
     private   int  shotValue  =   0 ;
    
     public   Shot ( int  ballCount ,   int  ballValue )   {  shotCount  =  ballCount ;  shotValue  =  ballValue ;   }

     public   int  getShotCount ()   {   return  shotCount ;   }
     public   int  getShotValue ()   {   return  shotValue ;   }
}