Problem with inheritance class
              in 
             Programming Questions 
              •  
              7 months ago    
            
 
           
             hi guys, at the moment im having this problem, ill show you the code first though
            
             
            
            
             
            
            
             
              
             
             
                
             
             
                
             
             
                  
             
             
            
             
            
            
             
            
            
             
            
            
             
              
             
             
              
             
             
               
             
             
            
             
            
            
             
            
            
             
            
            
 
            
           
             base class: 
            
            
              //base class
             
             
              class Enemy{
             
             
                float posX;
             
             
                float posY;
             
             
                boolean kill;
             
             
                int typeScore;
             
             
                Enemy() {
             
             
                  posX = width+(int)random(500,1500);
             
             
                  kill = false;
             
             
                }
             
             
                void display(){
             
             
               } 
             
             
              }
             
            
             subclass for enemy type:
            
            
              class Wretch extends Enemy
             
             
              {
             
             
                  Wretch() {
             
             
                  super();
             
             
                  typeScore = 3;
             
             
              }
             
             
                 void display(){
             
             
                  if(kill == false){
             
             
                  image(wretch,posX,375);
             
             
                  posX -= 5;
             
             
                }
             
             
                    if(posX < 55)
             
             
                    state = 4;
             
             
                }
             
             
              }
             
            
             basically i have a function on my player which is called 'attack' and it is a boolean that is initiated true when the key 'e' is pressed, what i basically want is for this enemy to not die after one hit but after two. i had the idea of putting an integer variable called healthbar that would -1 when attack = true and when healthbar was = 0 kill = true. however i have been trying this and it does not work.
            
            
             anyone have any suggestions...?
            
            
             thanks
            
 
            
              
              1  
            
 
            