Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace POO
- {
- class Persona
- {
- private string Nombre;
- //private string Apellido;
- public string Apellido { get; set; }
- private int _edad;
- public int Edad
- {
- get { return this._edad; }
- set {
- if (value > 0)
- {
- this._edad = value;
- }
- }
- }
- // Metodos Modificadores/Analizadores
- // Metodo SET - Nombre
- public void setNombre(string _nom)
- {
- this.Nombre = _nom;
- }
- // Método GET - Nombre
- public string getNombre()
- {
- return this.Nombre;
- }
- // Constructor vacío
- public Persona()
- {
- Console.WriteLine("Se creó el objeto ...");
- }
- // Constructor con parámetros
- public Persona(string _nombre, string _apellido, int _edad)
- {
- this.Nombre = _nombre;
- this.Apellido = _apellido;
- this.Edad = _edad;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment