1. 程式人生 > >C#(.NET)面試題:做一個能自定義輸入命令的表格程序

C#(.NET)面試題:做一個能自定義輸入命令的表格程序

rom info rate align alloc https att height 寬度

目前為止,已經面試 5 家了。

試題是英文的(後面給出翻譯):

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)

您可以編寫一個簡單的程序,其中一個和用戶可以執行一些基本的電子表格操作(即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
  • 退出
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

您可以編寫一個控制臺或瀏覽器應用程序,以提供C# 或javascript中提到的交互式用戶體驗。

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

假設每個單元格最多分配3個字符,因此此處給出的數字應相應地右對齊。

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

代碼需要托管在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

如果程序正在驗證用戶數據,並考慮邊緣情況

if the program is tested accordingly

如果程序被相應地測試

- - - - - - - - -

就是說設計一個程序,使程序能夠捕獲用戶輸入,並且能夠創建表格、處理單元格內容。當然這不是Excel表格。

技術分享圖片

要求是:

  • 能夠處理以上列出的命令,完成功能邏輯。並且能夠識別、處理無效指令
  • 避免出現異常,能夠正確處理程序
  • 能夠限制表格邊界
  • 正確處理用戶指令,用戶輸入的指令錯誤、超出預設範圍等時,程序不出現崩潰。

我實現的程序如下(gif動圖)

技術分享圖片

有效控制和正確識別指令

技術分享圖片

項目地址:

https://github.com/whuanle/GenerateTable

筆者項目上傳的 ReadMe.MD 文件是英文的,翻譯一下就好。主要問題也在這裏說明了。

項目使用了 StyleCop.Analyzers 代碼質量審查工具,對程序的代碼質量進行審查。

無論你怎麽輸入,不會因為你的錯誤指令使程序崩潰。

使用高內聚、低耦合的思路進行設計,避免函數式、If/else式編程。

技術分享圖片

要求:

VS 2017

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

C#(.NET)面試題:做一個能自定義輸入命令的表格程序