Hi
I like some beginnerhelp in C# and the basics of OOP. I have coded a bit but need some further guidance to continue.
This is an application with the purpose for my own training in capsulation, Inheritance and Polymorphism. Also see the attached image of user interface.
I need some help with example code to do the followed things.
As a first step I like to do is to use the input fields Nickname, Sort and Housing and number of legs to populate a listbox. The next steps will be to change and delete those values, but now I will be happy if I can get some help with the ADD issue.
This version contain only one abstract class as shown, but later I will have some more.
My questions and need for some helping code:
1. How can I populate a listbox with columns with values from the input ?
2. How can I use the abstract class to acheive that
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Assignment1
{
public partial class Form1 : Form
{
private void Form1_Load(object sender, System.EventArgs e)
{
}
//Dropdown
public enum Sort
{
Horse,
Dog,
Wolf,
Giraff
}
// Dropdown
public enum HousingType
{
Stable,
Cage,
Indoor,
Outdoor
}
// Constructor
public Form1()
{
InitializeComponent();
cmbSort.DataSource = Enum.GetValues(typeof(Sort));
cmbHousing.DataSource = Enum.GetValues(typeof(HousingType));
}
}
// Abstract class (Animaldetails)
public abstract class Animal
{
// Constructor
public Animal()
{
this.m_idNumber = 0;
this.m_name = "";
this.m_numberOfLegs = 0;
}
// Private fields
private int m_idNumber;
private string m_name;
private int m_numberOfLegs;
// Public values
public int idNumber
{
get { return this.m_idNumber; }
set { this.m_idNumber = value; }
}
public string name
{
get { return this.m_name; }
set { this.m_name = value; }
}
public int numberOfLegs
{
get { return this.m_numberOfLegs; }
set { this.m_numberOfLegs = value; }
}
}
}