Mickeys
asked on
How can I throw a AnimalDontEatThisException
in my planteater class I got this one:
public override String eat(string food)
Instead of returning a "Usschhhhhhh" when the animal don like the food I am supposted to throw a AnimalDontEatThisException . How?
Can I code so it does the same thing as now but throws the exception???
Show me please
public override String eat(string food)
Instead of returning a "Usschhhhhhh" when the animal don like the food I am supposted to throw a AnimalDontEatThisException
Can I code so it does the same thing as now but throws the exception???
Show me please
IAnimal.cs
---------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace Animals
{
/// <summary>
/// IAnimal Interface
/// </summary>
public interface IAnimal
{
/// <summary>
/// Eat method
/// </summary>
/// <param name="food"></param>
/// <returns></returns>
String eat(String food);
/// <summary>
/// set the ID number
/// </summary>
/// <param name="id"></param>
void setIDNumber(String id);
/// <summary>
/// Gets ID
/// </summary>
String ID
{
get;
} //end getID
/// <summary>
/// set the Name
/// </summary>
/// <param name="name"></param>
void setName(String name);
/// <summary>
///
/// </summary>
int NumberOfLegs
{
get;
}
/// <summary>
/// set the NumberofLegs
/// </summary>
/// <param name="numOfLegs"></param>
void setNumberOfLegs(int numOfLegs);
/// <summary>
/// Gets and Sets Name
/// </summary>
String Name
{
get;
} //end Name
/// <summary>
/// Gets and Sets Speed
/// </summary>
String Speed
{
set;
get;
} //end speed
/// <summary>
/// Gets Housing
/// </summary>
HousingType Housing
{
get;
} //end getHousing
/// <summary>
/// Sets and gets Aggressive
/// </summary>
bool Aggressive
{
set;
get;
} //end Aggressive
/// <summary>
/// Sets Housing
/// </summary>
HousingType setHousing
{
set;
} //end setHousing
/// <summary>
/// Gets and Sets Category
/// </summary>
String Category
{
get;
set;
} //end Category
/// <summary>
/// Gets and sets Typ
/// </summary>
String Typ
{
get;
set;
} //end Typ
} //end interface
} //end namespace
-----------------------------------------
Animal.cs
-----------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace Animals
{
/// <summary>
/// Class Animal
/// </summary>
[Serializable]
[XmlInclude(typeof(Animal))]
[XmlInclude(typeof(MeatEater))]
[XmlInclude(typeof(PlantEater))]
[XmlInclude(typeof(Dog))]
[XmlInclude(typeof(Giraffe))]
[XmlInclude(typeof(Horse))]
[XmlInclude(typeof(Wolf))]
[XmlInclude(typeof(Duck))]
[XmlInclude(typeof(Tiger))]
[XmlInclude(typeof(Lion))]
[XmlInclude(typeof(Rabbit))]
[XmlInclude(typeof(Donkey))]
[XmlInclude(typeof(Cow))]
public abstract class Animal: IAnimal
{
#region Deklaration
[XmlAttribute]
private String name;
private String IDNumber;
private int numberOfLegs;
private HousingType livesIn;
private String category;
private String type;
private bool isAggressive;
#endregion
#region Konstruktor
/// <summary>
/// Animal Konstruktor
/// </summary>
public Animal()
{
this.name = String.Empty;
this.IDNumber = String.Empty;
this.numberOfLegs = 0;
HousingType house = new HousingType();
this.livesIn = house;
this.category = String.Empty;
this.type = String.Empty;
this.isAggressive = false;
} //end Animal
/// <summary>
/// Konstruktor till Animal
/// </summary>
/// <param name="name"></param>
/// <param name="ID"></param>
/// <param name="numberOfLegs"></param>
/// <param name="livesIn"></param>
/// <param name="category"></param>
/// <param name="type"></param>
public Animal(String name, String ID, int numberOfLegs, HousingType livesIn, String category, String type, String speed, bool isAggressive)
{
this.name = name;
this.IDNumber =ID;
this.numberOfLegs = numberOfLegs;
this.livesIn = livesIn;
this.category = category;
this.type = type;
this.isAggressive = isAggressive;
} //end Animal
#endregion
#region Egenskaper
/// <summary>
/// Gets and Sets Name
/// </summary>
public String Name
{
set { name = value; }
get { return name; }
} //end Name
/// <summary>
/// Gets and Sets Speed
/// </summary>
//public String Speed
//{
// set { speed = value; }
// get { return speed; }
//} //end speed
/// <summary>
/// Gets and Sets Speed
/// </summary>
public virtual String Speed
{
set { }
get { return string.Empty; }
} //end speed
/// <summary>
/// Gets ID
/// </summary>
public String ID
{
get { return IDNumber; }
} //end getID
/// <summary>
/// Gets NumberOfLegs
/// </summary>
public int NumberOfLegs
{
get { return numberOfLegs; }
} //end getNumberOfLegs
/// <summary>
/// Gets Housing
/// </summary>
public HousingType Housing
{
get { return livesIn; }
} //end getHousing
/// <summary>
/// Sets and gets Aggressive
/// </summary>
public bool Aggressive
{
set { isAggressive = value; }
get { return isAggressive; }
} //end Aggressive
/// <summary>
/// Sets Housing
/// </summary>
public HousingType setHousing
{
set { livesIn = value; }
} //end setHousing
/// <summary>
/// Gets and Sets Category
/// </summary>
public String Category
{
get { return category; }
set { category = value; }
} //end Category
/// <summary>
/// Gets and sets Typ
/// </summary>
public String Typ
{
get { return type; }
set { type = value; }
} //end Typ
#endregion
#region IAnimal Members
/// <summary>
/// Eat method
/// </summary>
/// <param name="food"></param>
/// <returns></returns>
public virtual string eat(string food)
{
return "Animal eat method";
} //end eat
/// <summary>
/// Sets Id number
/// </summary>
/// <param name="id"></param>
void IAnimal.setIDNumber(string id)
{
this.IDNumber = id;
} //end setIDNumber
/// <summary>
/// Sets Name
/// </summary>
/// <param name="name"></param>
void IAnimal.setName(string name)
{
this.name = name;
} //end setName
/// <summary>
/// Sets number of legs
/// </summary>
/// <param name="numOfLegs"></param>
void IAnimal.setNumberOfLegs(int numOfLegs)
{
this.numberOfLegs = numOfLegs;
} //end setNumberOfLegs
#endregion
#region Metoder
/// <summary>
/// Print
/// </summary>
/// <returns></returns>
public abstract String toString();
#endregion
} //end class
} //end namespace
------------------------------------------
PlanEater.cs
------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace Animals
{
/// <summary>
/// PlantEater class
/// </summary>
[Serializable]
[XmlInclude(typeof(PlantEater))]
public abstract class PlantEater : Animal
{
#region Deklaration
[XmlAttribute]
protected List<string> likes;
protected const String category = "PlantEater";
#endregion
#region Konstruktor
/// <summary>
/// PlantEater konstruktor
/// </summary>
public PlantEater()
{ }
/// <summary>
/// Konstruktor PlantEater
/// </summary>
/// <param name="name"></param>
/// <param name="ID"></param>
/// <param name="numberOfLegs"></param>
/// <param name="housing"></param>
/// <param name="type"></param>
public PlantEater(String name, String ID, int numberOfLegs, HousingType housing, String type, String speed, bool aggressive)
: base(name, ID, numberOfLegs, housing, category, type, speed, aggressive)
{
likes = new List<string>();
likes.Add("Leaves");
} //end PlantEater
#endregion
#region Methods
/// <summary>
/// Does it like it? Eat method
/// </summary>
/// <param name="food"></param>
/// <returns></returns>
public override String eat(string food)
{
foreach (string eat in likes)
{
if (eat.ToLower() == food.ToLower())
{
return "Yummy";
} //end if
} //end foreach
return "Uuuusccccccch";
} //end eat
/// <summary>
/// Print
/// </summary>
/// <returns></returns>
public override String toString()
{
return "MeatEeater klassen toString";
} //end ToString
#endregion
} //end class
} //end namespace
------------------------------
Horse.cs
----------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace Animals
{
/// <summary>
/// Horse Class
/// </summary>
[Serializable]
[XmlInclude(typeof(Horse))]
public class Horse : PlantEater
{
#region Deklaration
[XmlAttribute]
private const int numberOfLegs = 4;
private const String classHorse = "Horse";
string speed = "0";
#endregion
#region Konstruktor
/// <summary>
/// Horse Konstruktor
/// </summary>
public Horse()
{ }
/// <summary>
/// Konstruktor Horse
/// </summary>
/// <param name="name"></param>
/// <param name="ID"></param>
/// <param name="housing"></param>
public Horse(String name, String ID, HousingType housing, String speed, bool aggressive)
: base(name, ID, numberOfLegs, housing, classHorse, speed, aggressive)
{
this.speed = speed;
likes.Add("Hö");
} //end Horse
#endregion
#region Egenskaper
public override string Speed
{
set { speed = value; }
get { return speed; }
}
#endregion
} //end class
} //end namespace
-----------------------------------
FORM1.cs
--------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Serialization;
using Animals;
using UtilitiesLibrary;
namespace Modul1_Malmoe
{
/// <summary>
/// Class Animal
/// </summary>
[Serializable]
public partial class AnimalPark : Form
{
#region Variabler
//Dekalaration
private AnimalManager animalManager = new AnimalManager();
private string path = "";
private string pathxml = "";
#endregion
#region Konstruktor
/// <summary>
/// AnimalPark Konstruktor
/// </summary>
public AnimalPark()
{
InitializeComponent();
} //end region
#endregion
#region Methods
/// <summary>
/// Form1_Load
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{
//Initiate the Form
housingCombobox.DataSource = Enum.GetValues(typeof(HousingType));
sortComboBox.DataSource = Enum.GetValues(typeof(MeatDjur));
nrOfLegsTextBox.Text = "4";
nrOfItems.Text = Convert.ToString(animalManager.Counter);
//Sets buttons and Labels to the correct state
changeButton.Enabled = false;
deleteButton.Enabled = false;
speedLabel.Visible = false;
speedTextBox.Visible = false;
mealComboBox.Enabled = false;
mealButton.Enabled = false;
MealLabel.Text = "";
speedTextBox.Text = "";
} //end Form1_Load
/// <summary>
/// Add_Click when clicking button Add
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Add_Click(object sender, EventArgs e)
{
//Check if Nick Name TextBox is Empty
if (nickNameTextBox.Text.Trim() == String.Empty)
{
MessageBox.Show("Please write something in Nick Name before adding", "Information");
} //end if
//Check if Nick Name TextBox is Empty
else if (speedTextBox.Visible == true && speedTextBox.Text.Trim() == String.Empty)
{
MessageBox.Show("Please write something in Speed before adding", "Information");
} //end if
//if none of the above is true continue to Add Animal
else
{
string text = sortComboBox.SelectedItem.ToString();
String speed = "";
//if speed is visible then speed should be saved
if(speedTextBox.Visible == true)
speed = speedTextBox.Text;
//Se if checkbox for aggressive is checked
bool isAggressive = aggressivecheckBox.Checked;
if (sortComboBox.SelectedItem.ToString() == "Horse")
{
speed = speedTextBox.Text;
} //end if
//Add the animal
animalManager.AddNewAnimal(text, nickNameTextBox.Text, (HousingType)housingCombobox.SelectedIndex, speed, isAggressive);
//Counting should rise one
nrOfItems.Text = Convert.ToString(animalManager.Counter);
//Update GUI
Updater();
} //end else
} //end Add_Click
/// <summary>
/// sortComboBox_SelectedIndexChanged
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void sortComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
//Set the correct nr of legs on the animal
if (sortComboBox.SelectedItem.ToString() == "Dog" ||
sortComboBox.SelectedItem.ToString() == "Giraffe" ||
sortComboBox.SelectedItem.ToString() == "Wolf" ||
sortComboBox.SelectedItem.ToString() == "Horse" ||
sortComboBox.SelectedItem.ToString() == "Tiger" ||
sortComboBox.SelectedItem.ToString() == "Lion" ||
sortComboBox.SelectedItem.ToString() == "Rabbit" ||
sortComboBox.SelectedItem.ToString() == "Cow" ||
sortComboBox.SelectedItem.ToString() == "Donkey")
nrOfLegsTextBox.Text = "4";
else if (sortComboBox.SelectedItem.ToString() == "Duck")
nrOfLegsTextBox.Text = "2";
//If it is a horse show the speed input
if (sortComboBox.SelectedItem.ToString() == "Horse")
{
speedLabel.Visible = true;
speedTextBox.Visible = true;
} //end if
//if not a horse do not show speed input
else
{
speedLabel.Visible = false;
speedTextBox.Visible = false;
} //end else
} //end sortComboBox_SelectedIndexChanged
/// <summary>
/// Updater updates the gui
/// </summary>
private void Updater()
{
//Update the gridview
AnimalDataGridView.DataSource = null;
AnimalDataGridView.AutoGenerateColumns = true;
AnimalDataGridView.DataSource = animalManager.AnimalList;
nickNameTextBox.Text = "";
nrOfItems.Text = Convert.ToString(animalManager.Counter);
//If there are any animals in the list then you should be able to delete and add
if (animalManager.AnimalList.Count > 0)
{
deleteButton.Enabled = true;
addButton.Enabled = true;
} //end if
//Set the Buttons in correct state
else
{
deleteButton.Enabled = false;
changeButton.Enabled = false;
addButton.Enabled = true;
} //end else
} //end Updater
/// <summary>
/// selectedRowsButton_Click if a row is clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void selectedRowsButton_Click(object sender, DataGridViewCellEventArgs e)
{
//Show a message box of what to do and continue if pressing yes
if (MessageBox.Show("Fill in the correct values and press change to save it", "Change", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
//Fill out the form with all saved info on the animal that has been clicked
addButton.Enabled = false;
Int32 selected = AnimalDataGridView.CurrentRow.Index;
nickNameTextBox.Text = animalManager.AnimalList[selected].Name;
nrOfLegsTextBox.Text = Convert.ToString(animalManager.AnimalList[selected].NumberOfLegs);
String category = animalManager.AnimalList[selected].Category;
aggressivecheckBox.Checked = animalManager.AnimalList[selected].Aggressive;
//Fill out the mealbuttons so you can see what the animal eats
mealComboBox.Enabled = true;
mealButton.Enabled = true;
mealComboBox.DataSource = Enum.GetValues(typeof(Eat));
if (sortComboBox.SelectedItem.ToString() == "Horse")
{
speedTextBox.Text = animalManager.AnimalList[selected].Speed;
}
//Search for the correct housing
int nFoundEl = -1;
for (int i = 0; i < housingCombobox.Items.Count; i++)
{
if (housingCombobox.Items[i].ToString().Equals(animalManager.AnimalList[selected].Housing.ToString()))
nFoundEl = i;
if (nFoundEl >= 0)
{
housingCombobox.SelectedIndex = nFoundEl;
} //end if
} //end for
//Get the correct type of animal from the list
Type t = animalManager.AnimalList[selected].GetType();
//Check if the choosen animal is a planteater
if (category == "PlantEater")
{
sortComboBox.DataSource = Enum.GetValues(typeof(PlantDjur));
PlantRdioButton.Checked = true;
}
//if it is a meateater
else
{
sortComboBox.DataSource = Enum.GetValues(typeof(MeatDjur));
meatRadioButton.Checked = true;
}
//Set the correct sort in the Combobox of the animal
nFoundEl = -1;
for (int i = 0; i < sortComboBox.Items.Count; i++)
{
if (sortComboBox.Items[i].ToString() == t.Name)
nFoundEl = i;
if (nFoundEl >= 0)
{
sortComboBox.SelectedIndex = nFoundEl;
} //end if
} //end for
changeButton.Enabled = true;
} //end if
} //end selectedRowsButton_Click
/// <summary>
/// exitButton_Click if you Exit the program
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exitButton_Click(object sender, EventArgs e)
{
Application.Exit();
} //end exitButton_Click
/// <summary>
/// deleteButton_Click if deleting
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void deleteButton_Click(object sender, EventArgs e)
{
//Check if you really want to delete. If press yes then continoue
if (MessageBox.Show("Really delete?", "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
//Get the animal you want to delete and remove it
Int32 selected = AnimalDataGridView.CurrentRow.Index;
animalManager.AnimalList.RemoveAt(selected);
//Remove one animal from the counter
animalManager.Counter--;
mealButton.Enabled = false;
mealComboBox.Enabled = false;
MealLabel.Text = "";
//Update Gui
Updater();
changeButton.Enabled = false;
} //end if
} //end deleteButton_Click
/// <summary>
/// resetButton_Click Resets the input gui
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void resetButton_Click(object sender, EventArgs e)
{
//Put everthing to the startvalues
housingCombobox.DataSource = Enum.GetValues(typeof(HousingType));
meatRadioButton.Checked = true;
sortComboBox.DataSource = Enum.GetValues(typeof(MeatDjur));
aggressivecheckBox.Checked = false;
mealComboBox.DataSource = Enum.GetValues(typeof(Eat));
nrOfLegsTextBox.Text = "4";
nrOfItems.Text = Convert.ToString(animalManager.Counter);
nickNameTextBox.Text = "";
speedTextBox.Text = "";
mealButton.Enabled = false;
mealComboBox.Enabled = false;
MealLabel.Text = "";
//Is there any animals in the list?
if (animalManager.AnimalList.Count > 0)
{
deleteButton.Enabled = true;
addButton.Enabled = true;
} //end if
else
{
deleteButton.Enabled = false;
changeButton.Enabled = false;
addButton.Enabled = true;
} //end else
} //end resetButton_Click
/// <summary>
/// changeButton_Click to change the animal
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void changeButton_Click(object sender, EventArgs e)
{
//Save the things you have saved for the animal
Int32 selected = AnimalDataGridView.CurrentRow.Index;
////Check if Speed Text box is empty and if the combobox is selected to HORSE
if ((speedTextBox.Text.Trim() == String.Empty) && (sortComboBox.SelectedItem.ToString() == "Horse"))
{
MessageBox.Show("Please write something in Speed before adding", "Information");
} //end if
else{
//Remove the animal
animalManager.AnimalList.RemoveAt(selected);
animalManager.Counter--;
//Add new animal
Add_Click(this, EventArgs.Empty);
//Reset the gui
resetButton_Click(this, EventArgs.Empty);
//Show the animal is saved
MessageBox.Show("Saved", "Saved");
changeButton.Enabled = false;
mealButton.Enabled = false;
mealComboBox.Enabled = false;
MealLabel.Text = "";
}
} //end changeButton_Click
/// <summary>
/// meatRadioButton_CheckedChanged
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void meatRadioButton_CheckedChanged(object sender, EventArgs e)
{
sortComboBox.DataSource = Enum.GetValues(typeof(MeatDjur));
} //end meatRadioButton_CheckedChanged
/// <summary>
/// PlantRadioButton_CheckedChanged
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PlantRadioButton_CheckedChanged(object sender, EventArgs e)
{
sortComboBox.DataSource = Enum.GetValues(typeof(PlantDjur));
} //end PlantRadioButton_CheckedChanged
/// <summary>
/// mealButton_Click check feeding
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mealButton_Click(object sender, EventArgs e)
{
//Check if the animal eats
Int32 selected = AnimalDataGridView.CurrentRow.Index;
MealLabel.Text = animalManager.AnimalList[selected].eat(mealComboBox.SelectedItem.ToString());
} //end mealButton_Click
/// <summary>
/// exitToolStripMenuItem_Click close the app
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
} //end exitToolStripMenuItem_Click
/// <summary>
/// newToolStripMenuItem_Click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
//Set the GridView to empty
AnimalDataGridView.DataSource = new int[0];
//Update the GUI
animalManager = null;
animalManager = new AnimalManager();
Updater();
} //end newToolStripMenuItem_Click
/// <summary>
/// openToolStripMenuItem_Click open a file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
//If you want to open a file
OpenFileDialog openExtensFile = new OpenFileDialog();
openExtensFile.Title = "C#";
openExtensFile.InitialDirectory = @"c:\";
openExtensFile.Filter = "*.ser|*.ser*|All files (*.*)|*.*";
openExtensFile.FilterIndex = 2;
openExtensFile.RestoreDirectory = true;
//When choosed file click OK button for opening
if (openExtensFile.ShowDialog() == DialogResult.OK)
{
//Save path so you know if you have open a file (incase you should use Save button)
path = openExtensFile.FileName.ToString();
// DeSerialize the object and open it
Object obj = Serialization.binaryFileDeSerialize<AnimalManager>(openExtensFile.FileName.ToString());
//Update the list and GUI
animalManager = (AnimalManager)obj;
Updater();
} //end if
} //end openToolStripMenuItem_Click
/// <summary>
/// saveToolStripMenuItem_Click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
//If never saved before then we need to use Save as
if (path.Equals(""))
{
saveAsToolStripMenuItem_Click(sender, e);
} //end if
else
{
//If saved before then we need to save it to the same file
Object obj = animalManager;
Serialization.binaryFileSerialize(obj, path);
} //end else
} //end saveToolStripMenuItem_Click
/// <summary>
/// saveAsToolStripMenuItem_Click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
//If a file never been saved before we need to create a file
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
saveFileDialog1.Filter = "*.ser|*.ser|All Files (*.*)|*.*" ;
saveFileDialog1.FilterIndex = 1;
//When choosing name of file then click ok
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
//Make the list an object and serilaze it and save it to the harddrive
Object obj = animalManager;
path = saveFileDialog1.FileName;
Serialization.binaryFileSerialize(obj, saveFileDialog1.FileName);
} //end if
} //end saveAsToolStripMenuItem_Click
/// <summary>
/// exportToXMLToolStripMenuItem_Click makes a xml file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exportToXMLToolStripMenuItem_Click(object sender, EventArgs e)
{
//Save the file as an xml file
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
saveFileDialog1.Filter = "*.xml|*.xml|All Files (*.*)|*.*";
saveFileDialog1.FilterIndex = 1;
//When choosing a name and pressed save
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
//Make an object. Save it as a xml file
Object obj = animalManager;
pathxml = saveFileDialog1.FileName;
Serialization.xmlFileSerialize<AnimalManager>(saveFileDialog1.FileName, (AnimalManager)obj);
} //end if
} //end exportToXMLToolStripMenuItem_Click
#endregion
} //end class
} //end namespace
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My planteater is in a dll and my animalpark is in my project
What more do I need?