Redian新闻
>
几年前在版上见过一个大牛写的一首诗,内容大概是异性吸引,精
avatar
几年前在版上见过一个大牛写的一首诗,内容大概是异性吸引,精# Biology - 生物学
c*e
1
这个Strategy design pattern的例子为什么人为得弄得这么复杂?
#include
#include
#include
using namespace std;
class Strategy;
class TestBed
{
public:
enum StrategyType
{
Dummy, Left, Right, Center
};
TestBed()
{
strategy_ = NULL;
}
void setStrategy(int type, int width);
void doIt();
private:
Strategy *strategy_;
};
class Strategy
{
public:
Strategy(int width): width_(width){}
void format()
{
char line[80], word[30];
ifstream inFile("quote.txt", ios::in);
line[0] = '\0';
inFile >> word;
strcat(line, word);
while (inFile >> word)
{
if (strlen(line) + strlen(word) + 1 > width_)
justify(line);
else
strcat(line, " ");
strcat(line, word);
}
justify(line);
}
protected:
int width_;
private:
virtual void justify(char *line) = 0;
};
class LeftStrategy: public Strategy
{
public:
LeftStrategy(int width): Strategy(width){}
private:
/* virtual */void justify(char *line)
{
cout << line << endl;
line[0] = '\0';
}
};
class RightStrategy: public Strategy
{
public:
RightStrategy(int width): Strategy(width){}
private:
/* virtual */void justify(char *line)
{
char buf[80];
int offset = width_ - strlen(line);
memset(buf, ' ', 80);
strcpy(&(buf[offset]), line);
cout << buf << endl;
line[0] = '\0';
}
};
class CenterStrategy: public Strategy
{
public:
CenterStrategy(int width): Strategy(width){}
private:
/* virtual */void justify(char *line)
{
char buf[80];
int offset = (width_ - strlen(line)) / 2;
memset(buf, ' ', 80);
strcpy(&(buf[offset]), line);
cout << buf << endl;
line[0] = '\0';
}
};
void TestBed::setStrategy(int type, int width)
{
delete strategy_;
if (type == Left)
strategy_ = new LeftStrategy(width);
else if (type == Right)
strategy_ = new RightStrategy(width);
else if (type == Center)
strategy_ = new CenterStrategy(width);
}
void TestBed::doIt()
{
strategy_->format();
}
int main()
{
TestBed test;
int answer, width;
cout << "Exit(0) Left(1) Right(2) Center(3): ";
cin >> answer;
while (answer)
{
cout << "Width: ";
cin >> width;
test.setStrategy(answer, width);
test.doIt();
cout << "Exit(0) Left(1) Right(2) Center(3): ";
cin >> answer;
}
return 0;
}
/* Input: 2 \ 75 \ 3 \ 75 \ 0
output:
Exit(0) Left(1) Right(2) Center(3): 2
Width: 75
Exit(0) Left(1) Right(2) Center(3): 3
Width: 75 */
avatar
l*z
2
LA念書,年方二十。
家人不让买二手车。
預算1W6 本來想16,800 砍 烤肉啦 S的,
後來17,500也勉強接受``
但現在疯田问题太多```就猶豫了``
听了几个网友建议,觉得focus不错(cobalt 也看了下,但車小馬力大,怕不安全)
上网看了看配置发觉focus还是比corolla少了点东西
像是Vehicle Speed Proportional Power Steering ,4 Wheel ABS,EBD, ETC,
Brake Assist System,Remote Fuel Filler Door Release,Cabin Air Filter
(第一个是助动回方向盘吧? 第2~3 觉得安全相关, 第4个以后就无关打紧了)
而且空间也相对较小
focus 3,500的rebate挺吸引的,觉得可以15k一下出门
kbb的resale value 一开始也让我心凉了半截,
不过rebate差价2500基本补回两车价值差不多了···
不知大家focus用得怎樣?
avatar
c*0
3
rt
avatar
t*g
4
AdvanceTrac® Electronic Stability Control (ESC) with anti-lock brakes (
ABS) is now standard on every Ford Focus. This state-of-the-art system
constantly monitors road conditions and the driver's responses, then adjusts
engine torque and applies the ABS brakes to help keep all the wheels firmly
planted. ESC brings an added measure of handling confidence to the fun-to-
drive agility you'd expect in a Ford Focus.
And the power steering is standard on foucs too,
the“EBD”is just a name from toyo
avatar
i*a
5
focus 無有 Cabin Air Filter??
what is Remote Fuel Filler Door Release?
Vehicle Speed Proportional Power Steering 是按車速度 調整輔助力
avatar
l*z
6
ETC=Electronic Traction Control
may be is a subsidiary support of ESC
i compare the cars on the toyota website....
R u sure it has a filter?
I know it do have air condition

(
adjusts
firmly
, it is a standard equipment on every model of focus now.

【在 t*****g 的大作中提到】
: AdvanceTrac® Electronic Stability Control (ESC) with anti-lock brakes (
: ABS) is now standard on every Ford Focus. This state-of-the-art system
: constantly monitors road conditions and the driver's responses, then adjusts
: engine torque and applies the ABS brakes to help keep all the wheels firmly
: planted. ESC brings an added measure of handling confidence to the fun-to-
: drive agility you'd expect in a Ford Focus.
: And the power steering is standard on foucs too,
: the“EBD”is just a name from toyo

avatar
l*z
7
I think is the place where u fill gasoline in ....
Yes,
Focus have Power steer but w/o proportional
does it matter?

【在 i****a 的大作中提到】
: focus 無有 Cabin Air Filter??
: what is Remote Fuel Filler Door Release?
: Vehicle Speed Proportional Power Steering 是按車速度 調整輔助力

avatar
l*z
8
今天去看了focus···
覺得它的dash board 很像玩具````
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。