- WPF users can save the zoo to a file.
saveButton to the MainWindow. Add a click event.MainWindow as specified in the diagram below.
SetWindowTitle method contains the following code// Set the title of the window using the current file name
this.Title = $"Object-Oriented Programming 2: Zoo [{Path.GetFileName(fileName)}]";SaveZoo method calls the SaveToFile method on the comoZoo field and then calls the SetWindowTitle method.save button.SaveFileDialog variable and then instantiate it to a new SaveFileDialog (in the Microsoft.Win32 namespace).Then set the dialog's Filter to the following string:
"Zoo save-game files (*.zoo)|*.zoo"true, call the SaveZoo method, passing in the dialog's FileName.if (dialog.ShowDialog() == true)save button. Choose a place to save the file and enter test.zoo as the file name.MainWindow title changes to: Object-Oriented Programming 2: [test.zoo]test.zoo file exists.load a saved zoo file.loadButton to the MainWindow. Add a click event.MainWindow as specified in the diagram below.
ClearWindow method, assign the ItemsSource for both the animal and guest list boxes to null.LoadZoo method.comoZoo field to the result of calling the Zoo's LoadFromFile method. Also, call the SetWindowTitle method, populate both list boxes, and call ConfigureBirthingRoomControls.load buttonOpenFileDialog variable and instantiate it to a new OpenFileDialog (in the Microsoft.Win32 namespace).Set its Filter to the same string as the SaveFileDialog.
If the result of showing the dialog is equal to true, clear the window and call the LoadZoo method, passing in the dialog's FileName.
Ensure Jimmy is no longer in the Zoo, that there aren't any guests and that the temperature is back to 77 degrees.
load button and choose your saved zoo file.The zoo should load successfully and Jimmy should be in the Zoo, the guest should be in the zoo and the temperature should be 60 degrees.
restartButton to the MainWindow. Add a click event.if (MessageBox.Show("Are you sure you want to start over?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
// code here
}comoZoo field by calling the Zoo's NewZoo method."Object-Oriented Programming 2: Zoo"ConfigureBirthingRoomControls.The list boxes should go back to the original animals, the guest should disappear and the temperature should revert.
MainWindow as specified in the diagram below.
AutoSaveFileName to "Autosave.zoo".LoadZoo method, initialize a result variable to true before the try...catch block.Set it to false in the catch block. Then return it.
window_Closing event, call the SaveZoo method, passing in the AutoSaveFileName.window_Loaded event, first call the LoadZoo method, passing in the autosave file name.If the result of that method is false, call the Zoo's NewZoo method. The code setting the temperature height and label, populating the combo box, and populating the list boxes should stay.
A message box should appear stating that a file could not be loaded. This is because there is not an autosave yet.
The Autosave.zoo file should be loaded automatically, and the guest should be in the list box.
Autosave.zoo file"Haliaeetus Leucocephalus" to the zoo."Haliaeetus Leucocephalus" should disappear."Haliaeetus Leucocephalus" should be in the animal list.© 2026 Northcentral Technical College