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
"
);
}
}
}
肩负责任,永不退缩
查看全文
相关阅读:
Python 7步机器学习
STL容器-- map and multimap 用法
STL容器-- forward_list 用法
STL容器-- fixed-size array 用法
STL容器-- deque 用法
网站502与504错误分析
git将一个分支的某个文件合并到当前分支
阿里云RDS上用mysqldump导入导出
mysqldump具体应用实例
mysql的导入导出工具mysqldump命令详解
原文地址:https://www.cnblogs.com/ATP/p/860645.html
最新文章
c语言冒泡排序算法
Delphi赋
原生javascript禁用和屏蔽鼠标右键
phalcon: 获取参数的方法
让 zend studio 识别 Phalcon语法并且进行语法提示
Phalcon处理404页面的 Ruter 方法
Phalcon 的 bootstrap.php 自动加载完成;非常人性化的设计
Phalcon 的分流bootstrap 设计 主程序入口
Linux 下 安装 Phalcon
GIT在Linux上的安装和使用简介
热门文章
phalcon在phpstorm里的配置视频
wamp虚拟机配置
phalcon的一些中文手册和帮助文档地址收集
phalcon安装和输出 hello word
script的defer和async
VS IDE 中Visual C++ 中的项目属性配置
Lib作为“静态库”与“动态库”中的区别
Hausdorff Distance(豪斯多夫距离)
U盘或者移动银盘退出时一直显示占用中问题解决--最粗暴解决方式
cmake 教程
Copyright © 2011-2022 走看看