Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Welcome");
- Hero Judas = new Hero("Judas", 120, 10);
- Hero Cain = new Hero("Cain", 140, 10);
- while (true)
- {
- int JudasAttack = Judas.Attack();
- Cain.takeDamage(JudasAttack);
- if (!Cain.isAlive())
- {
- Console.WriteLine("Judas Wins");
- break;
- }
- int CainAttack = Cain.Attack();
- Judas.takeDamage(CainAttack);
- if (!Judas.isAlive())
- {
- Console.WriteLine("Cain Wins");
- break;
- }
- }
- }
- }
- class Hero
- {
- public string name;
- public int health;
- public int damage;
- public Hero(string nName, int nHealth, int nDamage)
- {
- name = nName;
- health = nHealth;
- damage = nDamage;
- }
- public int Attack()
- {
- return damage;
- }
- public void takeDamage(int damageTaken)
- {
- health = health - damageTaken;
- }
- public bool isAlive()
- {
- if(health > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement