Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help!! Using Visual Studio, create a WinForms application that can load and save plain text files. This will be much like a simplified version

please help!!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Using Visual Studio, create a WinForms application that can load and save plain text files. This will be much like a simplified version of the Notepad utility application that comes with Microsoft Windows. This app will also include the ability to load text from a non-file source (Fibonacci in-memory sequence generator) Interface You are free to design the interface the way you wish for the most part, but you must include the following a prominent text area that contains the text o o o Use a TextBox control Set the Multiline property to true Set the ScrollBars property to Vertical or Both so that vertical scrolling can occur buttons or menu options to load and save files You will need 3 options for loading text, one from file, two from another source. This is discussed more below. o use OpenFileDialog/SaveFileDialog for selecting files to open/save o Can be created in code or at design time by dragging them in from the toolbox The image below shows an example of what the interface could look like 322 Notepad Gil 322 Notepad File File The image below shows an example of what the interface could look like 322 Notepad 322 Notepad 77: 3416454622906707 78: 5527939700884757 79:8944394323791464 80: 14472334024676221 81: 23416728348467685 82: 37889062373143906 83: 61305790721611591 84: 99194853094755497 85: 160500643816367088 86: 259695496911122585 87: 420196140727489673 88: 679891637638612258 89: 1100087778366101931 90: 1779979416004714189 91: 2880067194370816120 92: 4660046610375530309 93: 7540113804746346429 94: 12200160415121876738 95: 19740274219868223167 96: 31940434634990099905 97: 51680708854858323072 98: 83621143489848422977 99: 135301852344706746049 00: 218922995834555169026 Load from file... Load Fibonacci numbers (first 50) Load Fibonacci numbers (first 100) Save to file... 2 84: 99194853094755497 85: 160500643816367088 86: 259695496911122585 87: 420196140727489673 88: 679891637638612258 89: 1100087778366101931 90: 1779979416004714189 91: 2880067194370816120 92: 466004661037553030 93: 7540113804746346429 94: 12200160415121876738 95: 19740274219868223167 97: 51680708854858323072 98: 83621143489848422977 99:135301852344706746049 100: 218922995834555169026 Here's another image of the application scrolled up to the beginning numbers: 322 Notepad 8: 13 10: 34 11: 55 12: 89 13: 144 4: 233 15: 377 Saving Functionality (1 point Your application needs to provide the ability to save the text to a text file. Provide a button or menu option that brings up a SaveFileDialog, prompting the user for a file name. If the user clicks OK in that dialog, which you'll determine by checking the return value of the SaveFileDialog.ShowDialog function, Beupae return value then save the text in the text box to that file. You can save it using streams, text-writers, or any other method you see fit (it's the loading that's going to be more specific) Loading Functionality (8 points total 1. Generic Loading Function (1 point) write a function called "Load" or "LoadText" in your main form'sCS file. This will take a System.IO.TextReader object as a parameter. It should read all the text from the TextReader object and put it in the text box in your interface Declare and implement the method mentioned above private void LoadText(TextReader sr) a. b. Use either ReadToEnd or ReadLine (in a loop) to load all text from the reader and put it in the text box. This should replace any content already in the text box 2. Loading from file (1 point) Add the option to load text from a file. You can use a stream reader to open the file and pass it to your loading function. Remember that StreamReader inherits from TextReader and has a constructor that takes a file name as a parameter. Loading from FibonacciTextReader (6 points) write a class named FibonacciTextReader that inherits from the System.IOTextReader. Since you've implemented a loading function in part 1 that takes a text reader, you'll be able to pass this object to your loading function after creating an instance of it. This class must 3. Inherit from the TextReader class Make it have a constructor that takes an integer as a parameter indicating the maximum number of lines available (the maximum number of numbers in the sequence that you can generate) Override the ReadLine method which delivers the next number (as a string) in the Fibonaci sequence. You need logic in this function to handle the first two numbers as special cases. You must return null after the nth call, where n is the integer value passed to the constructor Override the ReadToEnd method if you used it back in the implementation for part1 Implement it such that it repeatedly calls ReadLine and concatenates all the lines together. You can use the System.Text.StringBuilder class to append the lines together into one string Use the System.Numerics.Biglnteger struct for the sequence numbers. The numbers get beyond what a 64-bit integer can store very quickly, so you need this to accurately a. b. c. d. e. Use the System.Numerics.Biglnteger struct for the sequence numbers. The numbers get beyond what a 64-bit integer can store very quickly, so you need this to accurately compute the first 100 numbers in the sequence. You may have to add a reference to the System.Numerics DLL in your project for this. Right-click references->Add reference-> find System.Numerics.dll e. Solution Notepad322 E-.Notepad322 References Microsoft.CSharp System .System.Core System.Data System.Data.DataSetExtensions System.Deployment System.Drawing System.Numerics System.Windows.Forms System.Xm System.Xml.Linq A Properties f. Optional: put the line number before the sequence number as shown in the sample app System.Core System.Data System.Dta.DaaSetExtensions System.Deployment System.Drawing System.Numerics System.Windows.Forms System.Xml System.Xml.Linq Properties f. Optional: put the line number before the sequence number as shown in the sample app screenshot Add three menu options (or buttons if you want) in your interface to allow for demonstration of the above functionality 4. There needs to be an option to load from a file. This should prompt the user for a file name (use OpenFileDialog for convenience) and then load it as described in #2 above There needs to be an option to load the first 50 numbers of the Fibonacci sequence There needs to be an option to load the first 100 numbers of the Fibonacci sequence (note: parts b and c should have almost identical code, just with a different number passed to the FibonacciTextReader constructor) a. b. c. d. 5. Put your name and ID number in a comment and the top of each code file that you write. Put a reasonable number of comments in your code. Point breakdown (the assignment is worth 10 points 2 points for correct saving functionality 4 points for correct loading function And as usual: 1 point: Code is clean, efficient and well organized 1 point: Quality of identifiers 1 point: Existence and quality of comments 1 point: Existence and quality of test cases

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

Describe how a tor browser might leak the identity of its user.

Answered: 1 week ago

Question

Relate costing methods to managerial decision making.

Answered: 1 week ago