Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Game design using object oriented system -
Object oriented design/system design
design a game
Version 1
single player
can attack or heal
fights computer
Version 2
single player
can attack or heal
fights computer
can select to be an attacker or healer, attacker has high attack power, healer has high healing power
attacker has 25 attack, 10 healing
healer has 10 attack, 25 healing
S.o.l.i.d -
code review - solid -> design -> facebook
close to your example ->
https://codereview.stackexchange.com/questions/177471/tic-tac-toe-with-solid-principles
https://codereview.stackexchange.com/questions/38789/clean-code-and-solid-principles-for-a-simple-python-tictactoe-game
http://juliachencoding.blogspot.ca/2015/12/oo-principle-solid-open-close-principle.html
https://codereview.stackexchange.com/questions/44606/simple-age-calculator/44643#44643
interface -> code to interface -> poly/ type - run time -> open/ close
pluralsight MIT - 3 hours -> design / code whole - javascript interface /
install eclipse -> home / visual studio /
OO - has -> one of input argument -> injection -> object -> cohesion -> too inter - loosely coupled
test - independency injection
software testing -> ask redesign -> test
abstract class Character{
Character enemy
String name
int HP
int attackPower
int healingPower
bool isAttacker
attack()
heal()
}
class GameEngine{
public static void RunTestcase()
{
var game = new Game();
var player = new Player();
player.attackPower = 25; // public get/ set
player.healPower = 10;
player.isAttacker = AssignDynamicRoleAttacker(player);
var players2 = new Player(); // domain / refine code later/ add factory pattern -> hacker first
// game / environment -> start game / determine - find two players ->
// one attacker/ one healer
}
}
class Player extends Character implements IParty{ // player
public int attackPower {get; set;} //
public int healingPower{ get; set;}
public bool isAttacker {get; set;}
public void Attack()
{}
public void Heal()
{}
public bool AssignDynamicRoleAttacker(character input) // attack 25 a, 10 heal
{
if(hasMoreAttackPower)
reture true;
else
return false;
}
private bool hasMoreAttackPower(character input)
{ // comparison of two power value
// business - change
return input.AttackerPower > input.HealPower; //
}
}
class Computer extends Character implements IParty{ // computer
}
// I - interface
// party - neutral object, person/ computer
// Learn C# Istring. Array ->
// 6000 C# quickly -> Interface, abstract,
// how to extract interface
// design/ learn how C# is Java
// https://csharp.2000things.com/
// https://csharp.2000things.com/index/
search items from #432 -> #1069 interface -> each one has code snippets
444 - interface can inherit other interface -> main interface / subinterface ->
438 - benenif fo using interface
interfaces
interface IParty{
public Attack()
public Heal()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.