Social Icons

viernes, 29 de julio de 2022

Ejempo en C# de Herencia y Arrays de Objetos en diferentes ficheros

Fiche1.cs:

namespace ArcGIS

{

    internal class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("===Punto=======");

            point pt1=new point("Locaciones","WGS84");

            pt1.getNombre();

            pt1.getSistemaRef();

            pt1.dibujarPunto(2,2);

            Console.WriteLine("===Poligono=======");

            poligono pg1 = new poligono("Cantones","WGS84");

            pg1.getNombre();

            pg1.getSistemaRef();

            pg1.DibujarPoligono();


            string n, s;

            Console.WriteLine("Ingrese los datos del nuevo Shapefile");

            n=Console.ReadLine();

            s=Console.ReadLine();


            poligono pg2 = new poligono(n, s);

;

            featureClass[] geodatabase = new featureClass[3];

            geodatabase[0] = pt1;

            geodatabase[1] = pg1;

            geodatabase[2] = pg2;

         



            Console.WriteLine("En la Geodatabase exisite: "+geodatabase.Length+" Features Class de tipo");


            for (int i = 0; i < geodatabase.Length; i++)

            {

                geodatabase[i].getNombre();

                geodatabase[i].getSistemaRef();


            }

    

            

        }


    }

}



Fichero2.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;





class featureClass

{

    //Propiedades

    private string nombre;

    private string sistemaRef;


    //Constructor

    public featureClass(string nombre2,string sistemaRef2)

    {

        nombre = nombre2;

        sistemaRef = sistemaRef2;

    }

        

    //Metodos

    public void getNombre()

    {

        Console.WriteLine("Nombre Feature Class: "+ nombre);

    }

    public void getSistemaRef()

    {

        Console.WriteLine("El sistema de Referencia es: " + sistemaRef);


    }



}

Fichero3.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class point:featureClass
{
    int x;
    int y;
    //Constructor 
    public point(string nombre, string sistemaRef):base(nombre,sistemaRef)
    {

    }
    public void dibujarPunto(int x, int y)
    {
        Console.WriteLine("Punto Dibujado: "+x+" ; "+y);    
    }

}



Fichero4.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class poligono:featureClass
{
    public poligono(string nombre, string sisteRef):base(nombre,sisteRef)
    {

    }
    public void DibujarPoligono()
    {
        Console.WriteLine("Poligono Dibujado");
    }

}


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