C#(.NET)面试题:做一个能自定义输入命令的表格程序

2019年12月15日 2517点热度 1人点赞 3条评论
内容纲要

目前为止,已经面试  5  10 家了。。。

这个试题面试的公司是某一上市公司。

试题是英文的(后面给出翻译):

you're given a task of writing a simple program where an and user will be able performing some basic spreadsheet operation(i.e. sum)

in a nutshell,the program should work as follows:

  • create a new spread shee
  • add number in different cells and perform some caculation on top of specific row or column
  •  Quit

您可以编写一个简单的程序,其中一个和用户可以执行一些基本的电子表格操作(即SUM)。

简而言之,程序的工作方式如下

  • 能够创建新的电子表格
  • 在不同的单元格中添加数字,并在特定的行或列的顶部执行一些计算
  • 能够退出
Commamd 命令 Description 描述
C w h should create a new spread sheet of width w and height h(i.e. the spreadsheet can hold w * h amount of cells)

应该创建一个宽度为w、高度为h的新电子表格(即电子表格可以容纳w*h的单元格数量)

N x1 y1 v1 should insert a number in specificed cell(x1,y1)

应在特定单元格中插入数字(x1,y1)

S x1 y1 x2 y2 x3 y3 should perform sum on top of all cells from x1 y1 to x2 y2 and store the result in x3 y3

应该在x1 y1到x2 y2的所有单元格上执行求和,并将结果存储在x3 y3中

Q Should quit the program

退出程序

 

you can write a console or browser application that will pro vide the interactive user experience in c# or javascript,mentioned in the problem statement

you can consider your choice of testing framework

assume each cell will allocate at most 3 characters,thus numbers given here should be right justified accordingly

please provide a read me document or text file,along with the submitted code,detailing instruction of running the application and tests,design considerations etc

the code is required to be hosted in apeivate repository in bitbucket. Bitbucket allows user create free private respositories

您可以编写一个控制台或浏览器应用程序,以提供C# 或javascript中提到的交互式用户体验

您可以考虑选择测试框架

假设每个单元格最多分配3个字符,因此此处给出的数字应相应地右对齐。

请提供一份自述文件或文本文件,连同提交的代码、运行应用程序和测试的详细说明、设计注意事项等。

代码需要托管在BitBucket中的Apeivate存储库中。BitBucket允许用户创建免费的私人呼吸

 

besides the code quality,we'll also check how you commit code(i.e. frequency,quality of commit comment,quality unit of code being committed etc)

the following assessment criteria's will be considered on the submitted code:

code quality(whether its following best practices with regard to design principles,patterns,algorithms)

if the program is validating user data,and considering edge cases

is the program is tested accordingly

除了代码质量,我们还将检查您如何提交代码(即频率、提交注释的质量、提交的代码的质量单位等)

提交的代码将考虑以下评估标准:

代码质量(是否遵循设计原则、模式、算法方面的最佳实践)

如果程序正在验证用户数据,并考虑边缘情况

程序是否被相应地测试

- - - - - - - - -

就是说设计一个程序,使程序能够捕获用户输入,并且能够创建表格、处理单元格内容。当然这不是指Excel表格。

要求是:

  • 能够处理以上列出的命令,完成功能逻辑。并且能够识别、处理无效指令
  • 避免出现异常,能够正确处理程序
  • 能够限制表格边界
  • 正确处理用户指令,用户输入的指令错误、超出预设范围等时,程序不出现崩溃。
  • 每个单元格只能有三个字符,不足三个字符时,左对齐

我实现的程序如下(gif动图)

有效控制和正确识别指令

项目地址:

https://github.com/whuanle/GenerateTable

笔者项目上传的 ReadMe.MD 文件是英文的,翻译一下就好。主要问题也在文章这里说明了。

项目使用了 StyleCop.Analyzers 代码质量审查工具,对程序的代码质量进行审查。

无论你怎么输入,不会因为你的错误指令使程序崩溃。

使用高内聚、低耦合的思路进行设计,避免函数式、If/else式编程。

 

要求:

VS 2017

.Net Core (最新 2.2,可支持不同版本)

 

痴者工良

高级程序员劝退师

文章评论