Chapter 10.
Alter the self-assessment question from the previous chapter so the Film class uses properties instead of get and set methods. Add validation code to set the rating to 10, if the user enters anything over 10, and set the rating to 0 if the user enters anything less than 0.
using
System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; namespace Films2{ class Class1 {
set { value; } } public int Rating{ get { return filmRating; } set { value; if (value > 10) if (value < 0)
} } } [STAThread]
do {
while (ans != "N");
new BinaryReader(File.Open("Film.dat", FileMode.Open)); film film2 = new film(); BinaryFormatter bm = new BinaryFormatter(); while (br.PeekChar() != -1) {
}
} |