Inheritance and Method help

spagii

New member
Joined
Mar 7, 2013
Messages
1
Programming Experience
1-3
Hello I need a help for a simple "game". It's super easy but since I'm a new to C# I'm having issues. I'm not asking for you to solve it but just to give me an idea how to start and how to continue, I tried to write sth but it's not right.


Need to write a class which implements IWorld and it's methods.

I tried to write sth:

[XCODE]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;




namespace PV178.Spring2013.Homework1
{
/// <summary>
/// Třída reprezentující herní svět.
/// </summary>
/// <remarks>
/// Herní svět má neměnný počet políček na šířku a na výšku. Horní políčko má souřadnice [0,0], kladná poloosa X
/// směřuje zleva doprava, kladná poloosa Y směřuje shora dolů.
/// </remarks>
///
[/XCODE]

This is what I wrote
[XCODE]

class GameWorld : IWorld
{


public void setDimension(int width_dimension, out int width_dimension1, int height_dimension,out int height_dimension1)
{

Width= width_dimension;
Heigth= height_dimension;




}


protected int Width;
protected int Height;


}

[/XCODE]


public interface IWorld
{
/// <summary>
/// Vrací šířku světa v počtu políček.
/// </summary>
int Width { get; }


/// <summary>
/// Vrací výšku světa v počtu políček.
/// </summary>
int Height { get; }


/// <summary>
/// Vrací počet políček, na kterých nestojí budovat.
/// </summary>
int FreeTiles { get; }




/// <summary>
/// Vrací souřadnice budovy ve světě.
/// </summary>
/// <param name="building">Hledaná budovat.</param>
/// <exception cref="InvalidOperationException">Budova není ve městě.</exception>
/// <exception cref="ArgumentNullException">
/// Budova je <c>null</c> .
/// </exception>
/// <returns>
/// Souřadnice budovy.
/// </returns>
///
public int getDimension()
{
return (Width);

}
ICoordinates GetBuildingLocation(IBuilding building);




/// <summary>
/// Finds building on the given coordinates.
/// </summary>
/// <param name="coordinates">Coordinates of the field.</param>
/// <returns>
/// returns building, on the given coordinates or <c>null</c> if the field is empty.
/// </returns>
/// <exception cref="ArgumentOutOfRangeException">Coordinates are out of the town dimension.</exception>
IBuilding GetBuildingAt(ICoordinates coordinates);




/// <summary>
/// Build building <paramref name="building" /> na souřadnice <paramref name="location" />.
/// </summary>
/// <param name="coordinates">Coordinates where the building will be build.</param>
/// <param name="building">Building</param>
/// <exception cref="InvalidOperationException">Building had been build somewhere else,or is already standing somewhere else or field is taken.</exception>
/// <exception cref="ArgumentNullException">Building null.</exception>
/// <exception cref="ArgumentOutOfRangeException">Souřadnice jsou mimo rozměry města.</exception>
void Build(ICoordinates coordinates, IBuilding building);




/// <summary>
/// Calculates the total tax sum from all building
/// </summary>
/// <returns>Total tax at FI$.</returns>
decimal CalculateLandTax();
}
[/XCODE]

again my part of the code
[XCODE]
class TestIWorld{


public void Main(string[] args)
{


GameWorld world = new GameWorld();


world.setDimension(10,20);


Console.WriteLine("Dimension is: {0}", world.getDimension());
Console.ReadKey();


}




}
}

[/XCODE]

Don't mind those stupids comments :)
 
Back
Top Bottom