Answer the question
In order to leave comments, you need to log in
How to build a modular architecture for a simple game?
There is a task. How to build architecture more competently. I made the first part.
But then I'm not sure that I'm doing everything right. My classes do not interact with each other, the class hierarchy should be separated from the implementation. And the "controller" should perform the main actions.
I don't know how to make it as modular as possible. MB should use some pattern. Sorry for the rather broad question.
using System;
namespace Game_taskApp
{
class Field
{
private int _weight;
private int _height;
public Field(int weight, int height)
{
if (weight < 15 || weight > 50) { weight = 15; }
if (height < 15 || height > 50) { height = 15; }
_weight = weight;
_height = height;
}
public int GetWeightField()
{
return _weight;
}
public int GetHeightField()
{
return _height;
}
}
class Bonus
{
private int _bonus;
public Bonus(int bonus)
{
if(bonus < 0 ||bonus > 15)
{
bonus = 10;
}
_bonus = bonus;
}
public int GetBonus()
{
return _bonus;
}
}
class Enemy
{
private int _quantity;
public Enemy(int quantity)
{
if (quantity < 0 || quantity > 10)
{
quantity = 10;
}
_quantity = quantity;
}
public int GetEnemiesCount()
{
return _quantity;
}
public void Walk()
{
}
}
class Wood
{
private int _wood;
public Wood(int wood)
{
if (wood > 10 || wood < 0)
{
wood = 10;
}
_wood = wood;
}
public int GetWood()
{
return _wood;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question