摘要:2023上半年軟件設計師下午的考試已結束,希賽小編整理了網友回憶版2023上半年軟件設計師下午真題答案(五),希望對考生有所幫助。
很多考生關注2023上半年軟件設計師下午的真題及答案,希賽小編整理了網友回憶版2023上半年軟件設計師下午真題答案(五),完整版真題可在本文文首或文末本文資料處下載。答案解析請考生關注考后公開課。
試題五:
閱讀下列說明和C++代碼,將應填入()處的字句寫在對應欄內。
說明:
在某系統(tǒng)中,類interval代表由下界(lower bound)和上界(upper bound)定義的區(qū)間。要求采用不同的格式顯示區(qū)間范圍。如【lower bound.upper bound】;【lower bound...upper bound】;【lower bound-upper bound】.等現(xiàn)采用策略(strategy)模式實現(xiàn)該要求,得到如圖6-1所示的類圖。
【c++代碼】
include using namespace std;
class Print strategy{
Public:
}(1) ;
class Interval{
Private:
double lower Bound;
double upper Bound;
Public
Interval (double P-lower,double P-upper ){
lower Bound=P-lower;
upper Bound=P-upper;
}void Print Interval (Print strategy prt ){
}2
double get lower (){
return lower Bound}
double get upper{
return upper Bound}
}
class Print Intervals (Comma: Public PrintsStrategy{
public:
void do Print (Interval *val ){
cout《“["《val→getLower()《“,”《val(→getupper()《”"]"《
end (:}
}:
class Print IntervalsDots :Public PrintStrategy{
Public:
void do Print (Interval*val(){
cout《"["《val→getLower()《"..."《val→getupper
()《"】"《
end li}
}:
class Print Intervals Line: Public PrintStrategy{
Public:
Void do Print (Interval*val(){
cout《"["《val→getLower()《“...”《val→getupper
()《"]”《
end li}
enum TYPE COMMA.DOTs.LINE}
Print strategy*get strategy cint type
Print strategy*sti
switch(type){
case COMMA:
(3);
break;
case Dots:
(4);
break:case LINE:
(5):
break:
}
return st;
}
int main(){
Interval a(1.7,2.1);
a.Print Interval(get strategy(commA);
a.Print Interval(get strategy(DoTs);
a.Print Interval(get strategy(LINE);
} return 0;
軟考備考資料免費領取
去領取