zoukankan
html css js c++ java
生产线模型
模型如下:
生产线(型号A)———〉生产汽车(型号A)———〉测试汽车(型号A)
要求:当更换生产线时对程序的改动要尽可能的少
using
System;
using
System.Collections.Generic;
using
System.Text;
namespace
ConsoleApplication1
{
class
Program
{
static
void
Main(
string
[] args)
{
string
NO;
NO
=
Console.ReadLine();
try
{
Produce(NO).MakeCar();
Produce(NO).TestCar();
}
catch
(NullReferenceException e)
{
Console.WriteLine(e.Message);
}
}
static
IProductLine Produce(
string
No)
{
if
(No
==
"
2000
"
)
{
return
new
Car_2000();
}
else
if
(No
==
"
3000
"
)
{
return
new
Car_3000();
}
else
{
Console.WriteLine(
"
你输入的型号不正确!
"
);
return
null
;
}
}
}
interface
IProductLine
{
void
MakeCar();
void
TestCar();
}
class
Car_2000 : IProductLine
{
public
void
MakeCar()
{
Console.WriteLine(
"
make car 2000
"
);
}
public
void
TestCar()
{
Console.WriteLine(
"
test car 2000
"
);
}
}
class
Car_3000 : IProductLine
{
public
void
MakeCar()
{
Console.WriteLine(
"
make car 3000
"
);
}
public
void
TestCar()
{
Console.WriteLine(
"
test car 3000
"
);
}
}
}
肩负责任,永不退缩
查看全文
相关阅读:
poj 2195 Going Home
poj 3068 "Shortest" pair of paths
aoj 2226 Merry Christmas
poj 2226 Muddy Fields
foj Problem 2275 Game
foj Problem 2283 Tic-Tac-Toe
XidianOJ 1081 锘爷与矩阵
XidianOJ 1061 a+boflw
XidianOJ 1080 锘爷与跳楼塔
XidianOJ 1017 Codeforce上的rating
原文地址:https://www.cnblogs.com/ATP/p/860645.html
最新文章
firefox快捷键
MyBatis的动态SQL详解
Spring整合Struts
Spring整合Hibernate的步骤
Struts2—整合Spring
预研报告——MyBatis持久层的demo
MyBatis实例教程--以接口的方式编程
Mapper的方式总结
MyBatis实例教程--开发环境搭建
Mybatis实例教程整体说明
热门文章
【CF】Codeforces1301D_Time to run
【模板】Johnson最短路_luoguP5905
【刷题】 [SDOI2010]魔法猪学院/luoguP2483_k短路_可持久化可并堆(并没有)
【日常训练】20200216_THOI2012network/hole_最短路/次短路
【日常训练】20200216_THOI2012waterlevel/stage_高精度
【日常训练】2020-02-08训练
poj 1418 Viva Confetti
2017百度之星 1003 度度熊与邪恶大魔王
poj 1981 Circle and Points
poj 3422 Kaka's Matrix Travels
Copyright © 2011-2022 走看看