Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Codigo:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Media;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace _1.__EspeciesAnimales

public partial class Form1 : Form

public Form1()

InitializeComponent();

private void comboBoxanimaltype_SelectedIndexChanged(object sender, EventArgs e)

comboBoxAnimal.DataSource = null;

List<string> listM = new List<string> { "Cat", "Dog", "Orca" };

List<string> listA = new List<string> { "Duck", "Hawk", "Hummingbird" };

switch (comboBoxanimaltype.SelectedIndex)

{
case 0:

comboBoxAnimal.DataSource = listM;

break;

case 1:

comboBoxAnimal.DataSource = listA;

break;

comboBoxAnimal.SelectedIndex = 0;

private void btnGenerate_Click(object sender, EventArgs e)

SoundPlayer simpleSound = new SoundPlayer();

switch (comboBoxAnimal.SelectedItem)

case "Cat":

ClsCat objGato = new ClsCat(txtname.Text, txtscientificname.Text,

Convert.ToDouble(txtweigth.Text), Convert.ToDouble(txtheigth.Text),

txtcolour.Text, txtlifetime.Text, "", txtgestationtime.Text,

Convert.ToInt32(txtjumpdistance.Text), comboBoxrace.SelectedItem.ToString());

richTextBox1.Text = objGato.ToString() + objGato.Feed() + objGato.Displace() +


objGato.Breathe() + objGato.Communicate();

simpleSound = new SoundPlayer(@"cat.wav");

break;

case "Dog":

ClsDog objDog = new ClsDog(txtname.Text, txtscientificname.Text,

Convert.ToDouble(txtweigth.Text), Convert.ToDouble(txtheigth.Text),

txtcolour.Text, txtlifetime.Text, "", txtgestationtime.Text,

Convert.ToInt32(txtjumpdistance.Text), comboBoxrace.SelectedItem.ToString());

richTextBox1.Text = objDog.ToString() + objDog.Feed() + objDog.Displace() +


objDog.Breathe() + objDog.Communicate();
simpleSound = new SoundPlayer(@"dog.wav");

break;

case "Orca":

ClsOrca objOrca = new ClsOrca(txtname.Text, txtscientificname.Text,

Convert.ToDouble(txtweigth.Text), Convert.ToDouble(txtheigth.Text),

txtcolour.Text, txtlifetime.Text, "", txtgestationtime.Text,

Convert.ToInt32(txtjumpdistance.Text), comboBoxrace.SelectedItem.ToString());

richTextBox1.Text = objOrca.ToString() + objOrca.Feed() + objOrca.Displace() +


objOrca.Breathe() + objOrca.Communicate();

//simpleSound = new SoundPlayer(@"orca.wav");

break;

case "Duck":

ClsDuck objDuck = new ClsDuck(txtname.Text, txtscientificname.Text,

Convert.ToDouble(txtweigth.Text), Convert.ToDouble(txtheigth.Text),

txtcolour.Text, txtlifetime.Text, "", txtgestationtime.Text

, comboBoxrace.SelectedItem.ToString());

richTextBox1.Text = objDuck.ToString() + objDuck.Feed() + objDuck.Displace() +


objDuck.Breathe() + objDuck.Communicate();

simpleSound = new SoundPlayer(@"duck.wav");

break;

case "Hawk":

ClsHawk objHauk = new ClsHawk(txtname.Text, txtscientificname.Text,

Convert.ToDouble(txtweigth.Text), Convert.ToDouble(txtheigth.Text),

txtcolour.Text, txtlifetime.Text, "", txtgestationtime.Text

, comboBoxrace.SelectedItem.ToString());

richTextBox1.Text = objHauk.ToString() + objHauk.Feed() + objHauk.Displace() +


objHauk.Breathe() + objHauk.Communicate();

simpleSound = new SoundPlayer(@"hawk.wav");

break;

case "Hummingbird":
ClsHummingbird objHummingbird = new ClsHummingbird(txtname.Text,
txtscientificname.Text,

Convert.ToDouble(txtweigth.Text), Convert.ToDouble(txtheigth.Text),

txtcolour.Text, txtlifetime.Text, "", txtgestationtime.Text

, comboBoxrace.SelectedItem.ToString());

richTextBox1.Text = objHummingbird.ToString() + objHummingbird.Feed() +


objHummingbird.Displace() + objHummingbird.Breathe() + objHummingbird.Communicate();

// simpleSound = new SoundPlayer(@"hummingbird.wav");

break;

simpleSound.Play();

private void comboBoxAnimal_SelectedIndexChanged(object sender, EventArgs e)

comboBoxrace.DataSource = null;

List<string> listracecat = new List<string> {"Persa", "Siames", "Angora", "Bengali",


"Siberiano" };

List<string> listracedog = new List<string> {"Beagle", "Pitbull", "Golden", "Husky", "Pug" };

List<string> listraceorca = new List<string> {"Residents", "Passersby", "Maritime" };

List<string> listraceduck = new List<string> {"Pekin", "Rouen", "Mexicano", "Campbell"};

List<string> listracehawk = new List<string> {"Merlin", "Alcotanes", "Kestrels", "Hawks" };

List<string> listracehummingbird = new List<string> {"Glittering", "Brown", "Purple-eared",


"Trochilinae" };

switch (comboBoxAnimal.SelectedItem)

case "Cat":

comboBoxrace.DataSource = listracecat;

pictureBox1.Image = Image.FromFile("cat.png");

break;
case "Dog":

comboBoxrace.DataSource = listracedog;

pictureBox1.Image = Image.FromFile("dog.png");

break;

case "Orca":

comboBoxrace.DataSource = listraceorca;

pictureBox1.Image = Image.FromFile("orca.png");

break;

case "Duck":

comboBoxrace.DataSource = listraceduck;

pictureBox1.Image = Image.FromFile("duck.png");

break;

case "Hawk":

comboBoxrace.DataSource = listracehawk;

pictureBox1.Image = Image.FromFile("hawk.png");

break;

case "Hummingbird":

comboBoxrace.DataSource = listracehummingbird;

pictureBox1.Image = Image.FromFile("hummingbird.png");

break;

private void comboBoxrace_SelectedIndexChanged(object sender, EventArgs e)

switch (comboBoxrace.SelectedItem)

case "Persa":

pictureBox1.Image = Image.FromFile("persa.png");
break;

case "Siames":

pictureBox1.Image = Image.FromFile("siames.png");

break;

case "Angora":

pictureBox1.Image = Image.FromFile("angora.png");

break;

case "Bengali":

pictureBox1.Image = Image.FromFile("bengali.png");

break;

case "Siberiano":

pictureBox1.Image = Image.FromFile("siberiano.png");

break;

case "Beagle":

pictureBox1.Image = Image.FromFile("Beagle.png");

break;

case "Pitbull":

pictureBox1.Image = Image.FromFile("Pitbull.png");

break;

case "Golden":

pictureBox1.Image = Image.FromFile("Golden.png");

break;

case "Husky":

pictureBox1.Image = Image.FromFile("Husky.png");

break;

case "Pug":

pictureBox1.Image = Image.FromFile("Pug.png");

break;

case "Residents":
pictureBox1.Image = Image.FromFile("Residents.png");

break;

case "Passersby":

pictureBox1.Image = Image.FromFile("Passersby.png");

break;

case "Maritime":

pictureBox1.Image = Image.FromFile("Maritime.png");

break;

case "Pekin":

pictureBox1.Image = Image.FromFile("Pekin.png");

break;

case "Rouen":

pictureBox1.Image = Image.FromFile("Rouen.jpg");

break;

case "Mexicano":

pictureBox1.Image = Image.FromFile("Mexicano.jpg");

break;

case "Campbell":

pictureBox1.Image = Image.FromFile("Campbell.jpg");

break;

case "Alcotanes":

pictureBox1.Image = Image.FromFile("Alcotanes.jpg");

break;

case "Kestrels":

pictureBox1.Image = Image.FromFile("Kestrels.png");

break;

case "Hawks":

pictureBox1.Image = Image.FromFile("Hawks.png");

break;
case "Glittering":

pictureBox1.Image = Image.FromFile("Glittering.png");

break;

case "Brown":

pictureBox1.Image = Image.FromFile("Brown.jpg");

break;

case "Purple-eared":

pictureBox1.Image = Image.FromFile("Purple-eared.png");

break;

case "Trochilinae":

pictureBox1.Image = Image.FromFile("Trochilinae.jpg");

break;

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

namespace _1.__EspeciesAnimales
{
internal abstract class ClsAnimal
{
protected string name;
protected string scientificname;
protected double weight;
protected double height;
protected string colour;
protected string timelife;
protected string imagen;

protected ClsAnimal(string name, string scientificname, double weight,


double height, string colour, string timelife, string imagen)
{
this.name = name;
this.scientificname = scientificname;
this.weight = weight;
this.height = height;
this.colour = colour;
this.timelife = timelife;
this.imagen = imagen;
}
public abstract string Feed();
public abstract string Breathe();
public abstract string Displace();
public abstract string Communicate();
public override string ToString()
{
return string.Format($"Name: {name}\nScientific Name: {scientificname}" +
$"\nWeight: {weight}\tHeight: {height}\nColour: {colour}\tTime Life: {timelife}");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal abstract class ClsMammals:ClsAnimal
{
protected string gestationtime;

protected ClsMammals(string name, string scientificname, double weight,


double height, string colour, string timelife, string imagen, string gestationtime):base(name, scientificname,
weight,
height, colour, timelife, imagen)
{
this.gestationtime = gestationtime;
}
public override string ToString()
{
return base.ToString() + "\nMammals (Mammalia) are a class of homeothermic (warm-blooded) amniotic
vertebrate animals that have milk-producing mammary glands with which they feed their young.\n";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal class ClsCat:ClsMammals
{
protected int jumpdistance;
protected string race;
public ClsCat(string name, string scientificname, double weight,
double height, string colour, string timelife, string imagen, string gestationtime, int jumpdistance, string race)
:base( name, scientificname, weight, height, colour, timelife, imagen, gestationtime)
{
this.jumpdistance = jumpdistance;
this.race = race;
}
public override string Feed()
{
return "\nIt is fed on croquettes ";
}
public override string Communicate()
{
return "\nPurr Maulla Miau ";
}
public override string Displace()
{
return "\nMoves to four limbs ";
}
public override string Breathe()
{
return "\nPulmonary Respitation ";
}
public override string ToString()
{
return base.ToString() + String.Format($"Jump distance: {jumpdistance}\tRace: {race}"); ;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal class ClsDog:ClsMammals
{
protected int jumpdistance;
protected string race;
public ClsDog(string name, string scientificname, double weight,
double height, string colour, string timelife, string imagen, string gestationtime, int jumpdistance, string race)
: base(name, scientificname, weight, height, colour, timelife, imagen, gestationtime)
{
this.jumpdistance = jumpdistance;
this.race = race;
}
public override string Feed()
{
return "\nIt is fed on croquettes ";
}
public override string Communicate()
{
return "\nBarks Wuaow ";
}
public override string Displace()
{
return "\nMoves to four limbs ";
}
public override string Breathe()
{
return "\nPulmonary Respitation ";
}
public override string ToString()
{
return base.ToString() + String.Format($"Jump distance: {jumpdistance}\tRace: {race}"); ;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal class ClsOrca:ClsMammals
{
protected int jumpdistance;
protected string race;
public ClsOrca(string name, string scientificname, double weight,
double height, string colour, string timelife, string imagen, string gestationtime, int jumpdistance, string race)
: base(name, scientificname, weight, height, colour, timelife, imagen, gestationtime)
{
this.jumpdistance = jumpdistance;
this.race = race;
}
public override string Feed()
{
return "\nThey feed on salmon, cod, herring, hake and halibut ";
}
public override string Communicate()
{
return "\nThey communicate using clicks and whistles that are very important to them ";
}
public override string Displace()
{
return "\nBody movement and fins ";
}
public override string Breathe()
{
return "\nPulmonary Respitation ";
}
public override string ToString()
{
return base.ToString() + String.Format($"Jump distance: {jumpdistance}\tRace: {race}"); ;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal abstract class ClsBirds:ClsAnimal
{
protected string gestationtime;
protected ClsBirds(string name, string scientificname, double weight,
double height, string colour, string timelife, string imagen, string gestationtime) : base(name, scientificname,
weight,
height, colour, timelife, imagen)
{
this.gestationtime = gestationtime;
}
public override string ToString()
{
return base.ToString() + "\nBirds are warm-blooded vertebrate animals that have a feathered body, wings as
forelimbs, and a beak ";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal class ClsDuck:ClsBirds
{
protected string race;
public ClsDuck(string name, string scientificname, double weight,
double height, string colour, string timelife, string imagen, string gestationtime, string race)
: base(name, scientificname, weight, height, colour, timelife, imagen, gestationtime)
{
this.race = race;
}
public override string Feed()
{
return "\nThey feed on algae, fish, plants, insects, seeds and some pebbles or sand ";
}
public override string Communicate()
{
return "\nshaking head and tail Cuack ";
}
public override string Displace()
{
return "\nMoves to two limbs ";
}
public override string Breathe()
{
return "\nPulmonary Respitation ";
}
public override string ToString()
{
return base.ToString() + String.Format($"\tRace: {race}"); ;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal class ClsHawk:ClsBirds
{
protected string race;
public ClsHawk(string name, string scientificname, double weight,
double height, string colour, string timelife, string imagen, string gestationtime, string race)
: base(name, scientificname, weight, height, colour, timelife, imagen, gestationtime)
{
this.race = race;
}
public override string Feed()
{
return "\nThey feed on insects, rodents, small and medium birds ";
}
public override string Communicate()
{
return "\nvisually or through sounds ";
}
public override string Displace()
{
return "\nThey fly with their two wings ";
}
public override string Breathe()
{
return "\nPulmonary Respitation ";
}
public override string ToString()
{
return base.ToString() + String.Format($"\tRace: {race}"); ;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1.__EspeciesAnimales
{
internal class ClsHummingbird:ClsBirds
{
protected string race;
public ClsHummingbird(string name, string scientificname, double weight,
double height, string colour, string timelife, string imagen, string gestationtime, string race)
: base(name, scientificname, weight, height, colour, timelife, imagen, gestationtime)
{
this.race = race;
}
public override string Feed()
{
return "\nIt feeds on the nectar of the flowers ";
}
public override string Communicate()
{
return "\nThey communicate through a variety of visual and vocalizations often performed in conjunction
with one another ";
}
public override string Displace()
{
return "\nThey fly with their two wings ";
}
public override string Breathe()
{
return "\nAerobic Respiration ";
}
public override string ToString()
{
return base.ToString() + String.Format($"\tRace: {race}"); ;
}
}
}

App:

You might also like