using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace BuilderModel
{
public class Bike
{
private int wheels;
public int Wheels { get { return wheels; } set { wheels = value; } }
private int frams;
public int Frams { get { return frams; } set { frams = value; } }
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace BuilderModel
{ public abstract class BuilderBike
{ public abstract void BuilWheels(int wheeels); public abstract void Buildframs(int frams);
public abstract Bike getBike();
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace BuilderModel
{
public class ConsBike:BuilderBike
{
Bike bike = new Bike();
public override Bike getBike()
{
return bike;
}
public override void BuilWheels(int wheels)
{
bike.Wheels = wheels;
}
public override void Buildframs(int frams)
{
bike.Frams = frams;
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace BuilderModel
{
public class DireBike
{
public void CreateBike(BuilderBike buildBike)
{
buildBike.Buildframs(1);
buildBike.BuilWheels(2);
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace BuilderModel
{
class Program
{
static void Main(string[] args)
{ BuilderBike buildBike = new ConsBike();
DireBike dirBike = new DireBike();
dirBike.CreateBike(buildBike);
Bike bike= buildBike.getBike();
Console.WriteLine("自行车的轮自有wheels="+bike.Wheels+"个"+" "+"架子frams="+bike.Frams+"个");
Console.ReadKey();
}
}
}