2. Design mode
One way to design this project.
Simple Factory mode
Console.WriteLine ("Please enter the notebook brand you Want");
String Brand=console.readline ();
NoteBook Nb=getnotebook (brand);
nb. SayHello ();//adjust which subclass of the method takes the object that is not in the parent class which child class to put.
The core of a simple factory that assigns values to the parent class based on the user's input
public static NoteBook Getnotebook (string brand)
{
NoteBook Nb=null;
Switch (brand)
{
Case "Lenovo": Nb=new Lenovo ();
Case "Acer": Nb=new Acer ();
}
return NB;
}
Public abstract class NoteBook
{
public abstract void SayHello ();
}
public class Lenovo:notbook
{
public override void SayHello ()
{
Console.WriteLine ("I'm a Lenovo notebook. ");
}
}
Public CALSS Acer:notebook
{
public override void SayHello ()
{
Console.WriteLine ("I Am a Acer notebook. ");
}
}
Simple Factory mode