Programming Logic Final Project Part 2
Hello Internet!!!
I am going to show off my final project for my logic/programming class.
If you go to THIS link, you can see the parameters of the project.
We were able to submit either a flowchart, pseudocode or the actual program for full credit.
We were also able to complete more than one for extra credit.
I chose to do both a flowchart and pseudocode.
This post will showcase my pseudocode.
Below is a video explaining my pseudocode and showing it off
And below is my actual pseudocode.
Hope everyone enjoys
I am going to show off my final project for my logic/programming class.
If you go to THIS link, you can see the parameters of the project.
We were able to submit either a flowchart, pseudocode or the actual program for full credit.
We were also able to complete more than one for extra credit.
I chose to do both a flowchart and pseudocode.
This post will showcase my pseudocode.
Below is a video explaining my pseudocode and showing it off
And below is my actual pseudocode.
//Declarations
public class Weapon
public class Character
private double probabilityOfHitting
public void setName(String newName)
name = newName
//name setter created
public void setProbabilityOfHitting( double newProbabilityOfHitting)
probabilityOfHitting = newProbabilityOfHitting
//probability of hitting setter created
public String getName()
return name
//created the name getter
public double getProbabilityOfHitting()
return probabilityOfHitting;
//created the probability of hitting getter
character 1 = player
character 2 = enemy
character 3 = enemy
player health = 5
enemy health = 5
Weapon = new Weapon ("rifle",(1.0/5.0)) // this shows how often the enemy rifle will hit
"rifle" hit -1 health // this states how much damage the enemy rifle will give to player
Weapon = new Weapon ("knife",(1.0/3.0)) // this shows how often the enemy knife will hit
"knife" hit -1 health // this states how much damage the enemy knife will give to player
Weapon = new Weapon ("mine",(1.0/10.00)) // this shows the probability of a mine detonating
"mine" explosion -3 health // this states how much damage a mine will give to player
Weapon = new Weapon ("grenade",(1.0/4.0)) // this shows how often the player grenade will hit
"grenade" hit -3 health // this states how much damage the player grenade will give to player
main()
playerMove //player searches for enemy
playerCombat //player encounters enemy
detailLoop()
playerAdvance //player advances on enemy
public void mine (player target)
double randomNum = random.nextDouble()
if (randomNum < this.probabilityOfHitting)
target -0 health
else
if (randomNum >= this.probabilityOfHitting)
target -3 health
//player steps on mine: yes/no?
if player health >0
and if player health <=2
player retreats
endLoop()
//player health check. player disengages from combat
else
if player health <=0
endLoop()
run enemy win scenario
if target distance > 30
public void rifle (enemy target)
double randomNum = random.nextDouble()
if (randomNum < this.probabilityOfHitting)
target -0 health
else
if (randomNum >= this.probabilityOfHitting)
target -1 health
//player shoots enemy: yes/no?
if enemy health >2
return()
if enemy health >0
and if enemy health <=2
enemy retreats //enemy health check. enemy disengages from combat
endLoop()
else
if enemy health <=0 enemy dies
if character 2 health <=0
and if character 3 health <=0
endLoop()
run player win scenario
else
if character 2 health <=0 && character 3 health >0
endLoop()
else
if character 2 health >0 && character 3 health <=0
endLoop()
if target distance <= 30
public void grenade (enemy target)
double randomNum = random.nextDouble()
if (randomNum < this.probabilityOfHitting)
target -0 health
else
if (randomNum >= this.probabilityOfHitting)
target -3 health
//player grenade hits enemy: yes/no?
if enemy health >2
return()
if enemy health >0
and if enemy health <=2
enemy retreats //enemy health check. enemy disengages from combat
endLoop()
else
if enemy health <=0 enemy dies
if character 2 health <=0
and if character 3 health <=0
endLoop()
run player win scenario
else
if character 2 health <=0 && character 3 health >0
endLoop()
else
if character 2 health >0 && character 3 health <=0
endLoop()
enemyAdvance //enemy advances on player
public void mine (enemy target)
double randomNum = random.nextDouble()
if (randomNum < this.probabilityOfHitting)
target -0 health
else
if (randomNum >= this.probabilityOfHitting)
target -3 health
//enemy steps on mine: yes/no?
if enemy health >0
and if enemy health <=2
enemy retreats
//enemy health check. enemy disengages from combat
else
if enemy health <=0
enemy dies
if character 2 health <=0
and if character 3 health <=0
endLoop()
run player win scenario
else
if character 2 health <=0 && character 3 health >0
endLoop()
else
if character 2 health >0 && character 3 health <=0
endLoop()
if target distance > 10
public void rifle (player target)
double randomNum = random.nextDouble()
if (randomNum < this.probabilityOfHitting)
target -0 health
else
if (randomNum >= this.probabilityOfHitting)
target -1 health
//enemy shoots player: yes/no?
if player health >2
return()
if player health >0
and if player health <=2
player retreats //player health check. player disengages from combat
endLoop()
else
if player health <=0 player dies
run enemy win scenario
if target distance <= 10
public void knife (player target)
double randomNum = random.nextDouble()
if (randomNum < this.probabilityOfHitting)
target -0 health
else
if (randomNum >= this.probabilityOfHitting)
target -1 health
//enemy knife hits player: yes/no?
if player health >2
return()
if player health >0
and if player health <=2
player retreats //player health check. player disengages from combat
endLoop()
else
if player health <=0 player dies
endLoop()
run enemy win scenario
end()
Hope everyone enjoys
Comments
Post a Comment