Lab2-Spring2022.zip

lab2/BaseballCards.java

lab2/BaseballCards.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  ist242 . labs . lab2 ;

/**
 *
 *  @author  psupo
 */
public   class   BaseballCards   {
     public   String  playerName ;
     public   String  position ;
     public   String  team ;
     public   int  hits ;
     public   int  rbis ;
     public   int  homeruns ;
    
     BaseballCards ( String  name ,   String  pos ,   String  team ,   int  hits ,   int  rbis ,   int  homeruns )   {
         this . playerName  =  name ;
         this . position  =  pos ;
         this . team  =  team ;
         this . hits  =  hits ;
         this . rbis  =  rbis ;
         this . homeruns  =  homeruns ;
     }

     public   String  getPlayerName ()   {
         return  playerName ;
     }

     public   void  setPlayerName ( String  playerName )   {
         this . playerName  =  playerName ;
     }

     public   String  getPosition ()   {
         return  position ;
     }

     public   void  setPosition ( String  position )   {
         this . position  =  position ;
     }

     public   String  getTeam ()   {
         return  team ;
     }

     public   void  setTeam ( String  team )   {
         this . team  =  team ;
     }

     public   int  getHits ()   {
         return  hits ;
     }

     public   void  setHits ( int  hits )   {
         this . hits  =  hits ;
     }

     public   int  getRbis ()   {
         return  rbis ;
     }

     public   void  setRbis ( int  rbis )   {
         this . rbis  =  rbis ;
     }

     public   int  getHomeruns ()   {
         return  homeruns ;
     }

     public   void  setHomeruns ( int  homeruns )   {
         this . homeruns  =  homeruns ;
     }

    @ Override
     public   String  toString ()   {
         return   "BaseballCards{"   +   "playerName="   +  playerName  +  
                 ", position="   +  position  +   ", team="   +  team  +
                 ", hits="   +  hits  +   ", rbis="   +  rbis  +
                 ", homeruns="   +  homeruns  +   '}' ;
     }     
}

lab2/BasketballCards.java

lab2/BasketballCards.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  ist242 . labs . lab2 ;

/**
 *
 *  @author  psupo
 */
public   class   BasketballCards   {
     public   String  playerName ;
     public   String  position ;
     public   String  team ;
     public   int  points ;
     public   int  assists ;
     public   int  blocks ;

     public   BasketballCards ( String  playerName ,   String  position ,   String  team ,   int  points ,   int  assists ,   int  blocks )   {
         this . playerName  =  playerName ;
         this . position  =  position ;
         this . team  =  team ;
         this . points  =  points ;
         this . assists  =  assists ;
         this . blocks  =  blocks ;
     }

     public   String  getPlayerName ()   {
         return  playerName ;
     }

     public   void  setPlayerName ( String  playerName )   {
         this . playerName  =  playerName ;
     }

     public   String  getPosition ()   {
         return  position ;
     }

     public   void  setPosition ( String  position )   {
         this . position  =  position ;
     }

     public   String  getTeam ()   {
         return  team ;
     }

     public   void  setTeam ( String  team )   {
         this . team  =  team ;
     }

     public   int  getPoints ()   {
         return  points ;
     }

     public   void  setPoints ( int  points )   {
         this . points  =  points ;
     }

     public   int  getAssists ()   {
         return  assists ;
     }

     public   void  setAssists ( int  assists )   {
         this . assists  =  assists ;
     }

     public   int  getBlocks ()   {
         return  blocks ;
     }

     public   void  setBlocks ( int  blocks )   {
         this . blocks  =  blocks ;
     }

    @ Override
     public   String  toString ()   {
         return   "BasketballCards{"   +   "playerName="   +  playerName  +  
                 ", position="   +  position  +   ", team="   +  team  +
                 ", points="   +  points  +   ", assists="   +  assists  +
                 ", blocks="   +  blocks  +   '}' ;
     }
    
    
}

lab2/CardSet.java

lab2/CardSet.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  ist242 . labs . lab2 ;

import  java . util . ArrayList ;

/**
 *
 *  @author  psupo
 */
public   class   CardSet   {
     public   ArrayList < BaseballCards >  baseballCards ;
     public   ArrayList < BasketballCards >  basketballCards ;
     public   ArrayList < FootballCards >  footballCards ;
     public   ArrayList < HockeyCards >  hockeyCards ;
     public   String  cardSetName ;
    
     CardSet ( String  name )   {
        baseballCards  =   new   ArrayList <> ();
        basketballCards  =   new   ArrayList <> ();
        footballCards  =   new   ArrayList <> ();
        hockeyCards  =   new   ArrayList <> ();
        cardSetName  =  name ;
     }

     public   String  getCardSetName ()   {
         return  cardSetName ;
     }

     public   void  setCardSetName ( String  cardSetName )   {
         this . cardSetName  =  cardSetName ;
     }

     public   void  addBaseballCard ( BaseballCards  card )   {
        baseballCards . add ( card );
     }
    
     public   void  removeBaseballCard ( int  index )   {
        baseballCards . remove ( index );
     }
    
     public   void  addBasketballCard ( BasketballCards  card )   {
        basketballCards . add ( card );
     }
    
     public   void  removeBasketballCard ( int  index )   {
        basketballCards . remove ( index );
     }
    
     public   void  addFootballCard ( FootballCards  card )   {
        footballCards . add ( card );
     }
    
     public   void  removeFootballCard ( int  index )   {
        footballCards . remove ( index );
     }
    
     public   void  addHockeyCard ( HockeyCards  card )   {
        hockeyCards . add ( card );
     }
    
     public   void  removeHockeyCard ( int  index )   {
        hockeyCards . remove ( index );
     }
    
    @ Override
     public   String  toString ()   {
         String  ts  =   "Card Set:\n"   +
                 "Card Set Name: "   +   this . cardSetName  +   ",\n"   +
                 "Baseball Cards:\n" ;
         for   ( BaseballCards  bb  :  baseballCards )
            ts  +=   "\t"   +  bb  +   "\n" ;
        ts  +=   "Basketball Cards:" ;
         for   ( BaseballCards  bb  :  baseballCards )
            ts  +=   "\t"   +  bb  +   "\n" ;
        ts  +=   "Football Cards:" ;
         for   ( FootballCards  fb  :  footballCards )
            ts  +=   "\t"   +  fb  +   "\n" ;
        ts  +=   "Hockey Cards:" ;
         for   ( HockeyCards  h  :  hockeyCards )
            ts  +=   "\t"   +  h  +   "\n" ;
         return  ts ;
     }
    
     public   static   void  main ( String []  args )   {
         CardSet  cs  =   new   CardSet ( "Top Deck 2022" );
        
        cs . addBaseballCard ( new   BaseballCards ( "Frank Thomas" ,   "First Base" ,   "Chicago White Sox" ,   185 , 115 , 24 ));
        cs . addBasketballCard ( new   BasketballCards ( "Shaquille O'Neal" ,   "Center" ,   "Orlando Magic" ,   2377 ,   195 ,   231 ));
        cs . addFootballCard ( new   FootballCards ( "Barry Sanders" ,   "Running Back" ,   "Detroit Lions" ,   2053 ,   11 ));
        cs . addHockeyCard ( new   HockeyCards ( "Sergei Fedorov" ,   "Center" ,   "Detroit Red Wings" ,   56 ,   64 ,   34 ,   "48" ));
    
         System . out . println ( cs );
     }
    
}

lab2/FootballCards.java

lab2/FootballCards.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  ist242 . labs . lab2 ;

/**
 *
 *  @author  psupo
 */
public   class   FootballCards   {
     public   String  playerName ;
     public   String  position ;
     public   String  team ;
     public   int  yards ;
     public   int  touchdowns ;

     public   FootballCards ( String  playerName ,   String  position ,   String  team ,   int  yds ,   int  tds )   {
         this . playerName  =  playerName ;
         this . position  =  position ;
         this . team  =  team ;
         this . yards  =  yds ;
         this . touchdowns  =  tds ;
     }

     public   String  getPlayerName ()   {
         return  playerName ;
     }

     public   void  setPlayerName ( String  playerName )   {
         this . playerName  =  playerName ;
     }

     public   String  getPosition ()   {
         return  position ;
     }

     public   void  setPosition ( String  position )   {
         this . position  =  position ;
     }

     public   String  getTeam ()   {
         return  team ;
     }

     public   void  setTeam ( String  team )   {
         this . team  =  team ;
     }

     public   int  getYards ()   {
         return  yards ;
     }

     public   void  setYards ( int  yards )   {
         this . yards  =  yards ;
     }

     public   int  getTouchdowns ()   {
         return  touchdowns ;
     }

     public   void  setTouchdowns ( int  touchdowns )   {
         this . touchdowns  =  touchdowns ;
     }

    @ Override
     public   String  toString ()   {
         return   "FootballCards{"   +   "playerName="   +  playerName  +
                 ", position="   +  position  +   ", team="   +  team  +
                 ", yards="   +  yards  +   ", touchdowns="   +  touchdowns  +   '}' ;
     }
    
    
}

lab2/HockeyCards.java

lab2/HockeyCards.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  ist242 . labs . lab2 ;

/**
 *
 *  @author  psupo
 */
public   class   HockeyCards   {
     public   String  playerName ;
     public   String  position ;
     public   String  team ;
     public   int  goals ;
     public   int  assists ;
     public   int  penaltyMins ;
     public   String  plusMinus ;

     public   HockeyCards ( String  playerName ,   String  position ,   String  team ,   int  goals ,   int  assists ,   int  penaltyMins ,   String  plusMinus )   {
         this . playerName  =  playerName ;
         this . position  =  position ;
         this . team  =  team ;
         this . goals  =  goals ;
         this . assists  =  assists ;
         this . penaltyMins  =  penaltyMins ;
         this . plusMinus  =  plusMinus ;
     }

     public   String  getPlayerName ()   {
         return  playerName ;
     }

     public   void  setPlayerName ( String  playerName )   {
         this . playerName  =  playerName ;
     }

     public   String  getPosition ()   {
         return  position ;
     }

     public   void  setPosition ( String  position )   {
         this . position  =  position ;
     }

     public   String  getTeam ()   {
         return  team ;
     }

     public   void  setTeam ( String  team )   {
         this . team  =  team ;
     }

     public   int  getGoals ()   {
         return  goals ;
     }

     public   void  setGoals ( int  goals )   {
         this . goals  =  goals ;
     }

     public   int  getAssists ()   {
         return  assists ;
     }

     public   void  setAssists ( int  assists )   {
         this . assists  =  assists ;
     }

     public   int  getPenaltyMins ()   {
         return  penaltyMins ;
     }

     public   void  setPenaltyMins ( int  penaltyMins )   {
         this . penaltyMins  =  penaltyMins ;
     }

     public   String  getPlusMinus ()   {
         return  plusMinus ;
     }

     public   void  setPlusMinus ( String  plusMinus )   {
         this . plusMinus  =  plusMinus ;
     }

    @ Override
     public   String  toString ()   {
         return   "HockeyCards{"   +   "playerName="   +  playerName  +
                 ", position="   +  position  +   ", team="   +  team  +
                 ", goals="   +  goals  +   ", assists="   +  assists  +  
                 ", penaltyMins="   +  penaltyMins  +  
                 ", plusMinus="   +  plusMinus  +   '}' ;
     }
    
    
}