软件工程师-主观题-远程

欢迎参加本次测试,测试时间为40分钟(至少选择2道题作答),测试期间请不要用互联网查询资料,或请求他人协助等一切作弊行为。如有违反,一律直接淘汰。

Q1:请填写个人信息

姓名
手机
应聘岗位
面试时间

Q2:阅读下列说明和图,回答问题1至问题3,将解答填入答题纸的对应栏内。【说明】某公司欲开发一个管理选民信息的软件系统。系统的基本需求描述如下:(1)每个人(Person)可以是一个合法选民(Eligible)或者无效的选民(Ineligible)。(2)每个合法选民必须通过该系统对其投票所在区域(即选区,Riding)进行注册( Registration)。每个合法选民仅能注册一个选区。(3)选民所属选区由其居住地址(Address)决定。假设每个人只有一个地址,地址可以是镇(Town)或者城市(City)。(4)某些选区可能包含多个镇;而某些较大的城市也可能包含多个选区。现采用面向对象方法对该系统进行分析与设计,得到如图1-1所示的初始类图。[图片]【问题1】根据说明中的描述,给出图1-1中C1~C4所对应的类名(类名使用说明中给出的英文词汇)。【问题2】根据说明中的描述,给出图1-1中M1~M6处的多重度。【问题3】现对该系统提出了以下新需求:(1)某些人拥有在多个选区投票的权利,因此需要注册多个选区;(2)对手满足(1)的选民,需要划定其“主要居住地”,以确定他们应该在哪个选区进行投票。为了满足上述需求,需要对图1-1所示的类图进行哪些修改?请用100字以内文字说明。

【问题1】(24分)
【问题2】(12分)
【问题3】(14分)

Q3:阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。备注:可以将以下代码翻译成自己擅长的语言之后,再回答相应的问题。【说明】某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。Command模式的类图如图1-1所示。[图片]【Java代码】class Light { public Light() {} public Light(String name) { /* 代码省略 */ } public void on() { /* 代码省略 */ } // 开灯 public void off() { /* 代码省略 */ } // 关灯 // 其余代码省略}(1) { public void execute();}class LightOnCommand implements Command { // 开灯命令 Light light; public LightOnCommand(Light light) { this.light=light; } public void execute() { (2) ; }}class LightOffCommand implements Command { // 关灯命令 Light light; public LightOffCommand(Light light) { this.light=light; } public void execute(){ (3) ; }}class RemoteControl { // 遥控器 Command[] onCommands=new Command[7]; Command[] offCommands=new Command[7]; public RemoteControl() { /* 代码省略 */ } public void setCommand(int slot, Command onCommand, Command offCommand) { (4) =onCommand; (5) =offCommand; } public void onButtonWasPushed(int slot) { (6) ; } public void offlButtonWasPushed(int slot){ (7) ; }}class RemoteLoader { public static void main(String[] args) { RemoteControl remoteControl=new RemoteControl(); Light livingRoomLight=new Light("Living Room"); Light kitchenLight=new Light("kitchen"); LightOnCommand livingRoomLightOn=new LightOnCommand(livingRoomLight); LightOffCommand livingRoomLightOff=new LightOffCommand(livingRoomLight); LightOnCommand kitchenLightOn=new LightOnCommand(kitchenLight); LightOffCommand kitchenLightOff=new LightOffCommand(kitchenLight); remoteControl.setCommand(0, livingRoomLightOn, livingRoomLightOff); remoteControl.setCommand(1, kitchenLightOn, kitchenLightOff); remoteControl.onButtonWasPushed(0); remoteControl.offButtonWasPushed(0); remoteControl.onButtonWasPushed(1); remoteControl.offButtonWasPushed(1); }}

【问题1】(8分)
【问题2】(7分)
【问题3】(7分)
【问题4】(7分)
【问题5】(7分)
【问题6】(7分)
【问题7】(7分)

Q4:阅读下列说明和Objective C代码,将应填入 (n) 处的字句写在答题纸的对应栏内。备注:可以将以下代码翻译成自己擅长的语言之后,再回答相应的问题。【说明】某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。Command模式的类图如图1-1所示。[图片]@interface Light : NSObject- (void)on;- (void)off;@end(1)- (void)execute;@end@interface LightOnCommand : NSObject Command@property (strong, nonatomic) Light *light;- (id)initWithLight:(Light *)light;@end@implementation LightOnCommand- (id)initWithLight:(Light *)light{ if (self = [super init]) { self.light = light; } return self;}- (void)execute{ (2)}@end@interface LightOffCommand : NSObject Command@property (strong, nonatomic) Light *light;- (id)initWithLight:(Light *)light;@end@implementation LightOffCommand- (id)initWithLight:(Light *)light{ if (self = [super init]) { self.light = light; } return self;}- (void)execute{ (3)}@end@interface RemoteControl : NSObject@property (strong, nonatomic) NSMutableArray* onCommands;@property (strong, nonatomic) NSMutableArray* offCommands;- (void)setCommandWithSlot:(int)slot onCommand:(idCommand)onCommand andOffCommand:(idCommand)offCommand;- (void)onButtonWasPushedAtSlot:(int)slot;- (void)offButtonWasPushedAtSlot:(int)slot;@end@implementation RemoteControl- (id)init{ if (self = [super init]) { self.onCommands = [NSMutableArray array]; self.offCommands = [NSMutableArray array]; } return self;}- (void)setCommandWithSlot:(int)slot onCommand:(idCommand)onCommand andOffCommand:(idCommand)offCommand{ (4) = onCommand; (5) = offCommand;}- (void)onButtonWasPushedAtSlot:(int)slot{ (6)}- (void)offButtonWasPushedAtSlot:(int)slot{ (7)}@endint main(int argc, const char * argv[]) { @autoreleasepool { RemoteControl *remoteControl = [[RemoteControl alloc] init]; Light *livingRoomLight = [[Light alloc] init]; Light *kitchenLight = [[Light alloc] init]; LightOnCommand *livingRoomLightOn = [[LightOnCommand alloc] initWithLight:livingRoomLight]; LightOffCommand *livingRoomLightOff = [[LightOffCommand alloc] initWithLight:livingRoomLight]; LightOnCommand *kitchenRoomLightOn = [[LightOnCommand alloc] initWithLight:kitchenLight]; LightOffCommand *kitchenRoomLightOff = [[LightOffCommand alloc] initWithLight:kitchenLight]; [remoteControl setCommandWithSlot:0 onCommand:livingRoomLightOn andOffCommand:livingRoomLightOff]; [remoteControl setCommandWithSlot:1 onCommand:kitchenRoomLightOn andOffCommand:kitchenRoomLightOff]; [remoteControl onButtonWasPushedAtSlot:0]; [remoteControl offButtonWasPushedAtSlot:0]; [remoteControl onButtonWasPushedAtSlot:1]; [remoteControl offButtonWasPushedAtSlot:1]; } return 0;}

【问题1】(8分)
【问题2】(7分)
【问题3】(7分)
【问题4】(7分)
【问题5】(7分)
【问题6】(7分)
【问题7】(7分)

Q5:阅读下列说明和C代码,回答问题1⾄至问题3,将解答写在答题纸的对应栏内。【说明】计算一个整数数组a的最长递增⼦子序列长度的⽅方法描述如下:假设数组a的长度为n,⽤用数组b的元素b[i]记录以a[i](0≤in)为结尾元素的最长递增予序列的长度,则数组a的最长递增⼦子序列的长度为[图片1];其中b[i]满⾜足最优子结构,可递归定义为:[图片2]【C代码】下面是算法的C语言实现。(1)常量和变量说明a:长度为n的整数数组,待求其最长递增⼦子序列b:长度为n的数组,b[i]记录以a[i](0≤in)为结尾元素的最长递增⼦子序列的长度,其中0≤inlen:最长递增子序列的长度i,j:循环变量temp:临时变量(2)C程序#include stdio.hint maxL(int*b, int n) { int i, temp=0; for(i=0; in; i++) { if(b[i]temp) temp=b[i]; } return temp;}int main(){ int n, a[100], b[100], i, j, len; scanf("%d", n); for(i=0; in; i++) { scanf("%d", a[i]); } (1) ; for(i=1; in; i++) { for(j=0, len=0; (2) ; j++) { if( (3) lenb[j]) len=b[j]; } (4) ; } printf("len:%d\n", maxL(b,n)); printf("\n");}【问题1】根据说明和C代码,填充C代码中的空(1)~(4)。【问题2】根据说明和C代码,算法采用了 (5) 设计策略,时间复杂度为 (6) (用O符号表示)。【问题3】已知数组a={3,10,5,15,6,8},根据说明和C代码,给出数组b的元素值。

【问题1】(24分)
【问题2】(14分)
【问题3】(12分)
问卷网
软件工程师-主观题-远程
关于
1年前
更新
1
频次
5
题目数
分享