Social Icons

jueves, 28 de julio de 2022

Ejemplo de Herencia y creación de array de objetos

punto pt1 = new punto("locacion", "UTM Z18S", "punto");

pt1.getInfoShapefile();


linea ln1 = new linea("vias", "UTM Z17S", "linea");

ln1.getInfoShapefile();


punto pt2 = new punto("poblado", "UTM Z18S", "punto");



Shapefile[] geodatabase = new Shapefile[5];  

geodatabase[0] = pt1;

geodatabase[1] = pt2;

geodatabase[2] = ln1;


Console.WriteLine("La Geodatabase contiene:");

foreach (Shapefile feature in geodatabase)

{

    Console.WriteLine(feature);


}






class Shapefile

{

    //definicion de parametros

    private string nombreshape;

    private string sistemaReferencia;

    private string geometria;


    public Shapefile(string nombre,string sistema,string geome)


        {

        nombreshape = nombre;

        sistemaReferencia = sistema;

        geometria = geome;

        }

    public void getInfoShapefile()

    {


        Console.WriteLine("Datos del Shapefile de: " + geometria + " tiene el nombre: " + nombreshape + " y sistema de referencia: " + sistemaReferencia);

    }




}


class punto : Shapefile

{

    private int x;

    private int y;


    public punto(string nombrepunto, string sistema, string geometria) : base(nombrepunto, sistema, geometria)

    {


    }

    public void tienez()

        {

        Console.WriteLine("Tiene z");

        }

}


class linea:Shapefile

{

    public linea(string nombrelinea, string sistema, string geometria) : base(nombrelinea, sistema, geometria)

    {

        

    }

    

    

    private int x;

    private int y;



}




No hay comentarios.:

Publicar un comentario

PELICULAS PARA VER

  Inexactitudes fácticas en las películas (msn.com) https://www.msn.com/es-co/entretenimiento/famosos/inexactitudes-f%C3%A1cticas-en-las-pel...

 
 
Blogger Templates