0% found this document useful (0 votes)
4 views1 page

Project 2 AlienShip

The document defines an abstract class 'AlienShip' in Java, which includes properties for shield strength and ship name, along with methods for firing weapons, detecting hits, and managing the number of ships. It tracks the total number of ships and handles the destruction of a ship when its shield strength reaches zero. The class utilizes logging for various actions within its methods.

Uploaded by

A A Mamun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Project 2 AlienShip

The document defines an abstract class 'AlienShip' in Java, which includes properties for shield strength and ship name, along with methods for firing weapons, detecting hits, and managing the number of ships. It tracks the total number of ships and handles the destruction of a ship when its shield strength reaches zero. The class utilizes logging for various actions within its methods.

Uploaded by

A A Mamun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package com.project22_8_21.

app;

import android.util.Log;

public abstract class AlienShip {


private static int numShips;
private int shieldStrength;
public String shipName;

public AlienShip(int shieldStrength){


Log.i("Location: ", "AlienShip constructor");
numShips++;
setShieldStrength(shieldStrength);
}

public abstract void fireWeapon();//Ahh my body

public static int getNumShips(){


return numShips;
}

private void setShieldStrength(int shieldStrength){


this.shieldStrength = shieldStrength;
}

public int getShieldStrength(){


return this.shieldStrength;
}

public void hitDetected(){


shieldStrength -=25;
Log.i("Incomiming: ", "Bam!!");
if (shieldStrength == 0){
destroyShip();
}

private void destroyShip(){


numShips--;
Log.i("Explosion: ", ""+this.shipName + " destroyed");
}

You might also like