Question: Overview: This Lab is a program to demonstrate Strings, the String Builder, and a program to demonstrate Regular Expressions This program accepts codes entered into

Overview: This Lab is a program to demonstrate Strings, the String Builder, and a program to demonstrate Regular Expressions

This program accepts codes entered into a textbox (simulating information coming in from a hand held scanner). This Program uses a StringBuilder to record the codes (to demonstrate its use) and uses String Functions to validate input

Create a C# Windows application. Change the title bar to the name of the company (you get to decide this yourself on this lab.)

Place 2 buttons on the form. One to scan a code (add it to the StringBuilder if it passes) and one to Display the log (of the codes.) Make sure to change the names of these controls to something appropriate. (Dont leave textboxes as Textbox1 or buttons as Button1.)

Create 2 StringBuilders named: strBldrlog (or buffercodes if you likebut give it a descriptive name in any case), and strBldrFails (or bufferFails) as class level variables (so it will remember the values between button presses.)

(Note: It is not clear in the text. But, here is the deal with strings and string builders. A string is used for most string objects in an OO language of this type. It saves memory by allowing multiple uses of the same word like John to all share the same reference and have only one place in memory they all use in something called the String Pool in the area of memory that stores objects. (This increased memory efficiency and program speed.) Butthis actually slows down the system if the same set of characters is being modified constantly and stored in one locationbecause the system searches for a match in the string pool, and either finds one or not, and if not it must call on the string constructor to create a new one.

It is more efficient to use an actual Buffer type data structure to hold highly mutable data that is going to be modified constantly by the program. In this program its being used to keep a transaction log on the device so it is going to be changing with use and will never repeat.)

In the code for the Scan button have it validate the code typed into that textfield. Use String methods from chapter 18 to make sure the code value typed by the user into its textbox is exactly 8 characters long and does not contain a space.

If it passed validation with the rules above Append the first three characters (lets say they are control codes, just to allow you to demonstrate a different set of String methods out of this chapter without writing more programs) to the StringBuilder recording the codes that pass in the order they were put in.

If it fails validationInsert the complete entry into the StringBuilder recording the ones that do not pass so the last one entered is the first one inside it.

The Second button should show the current values in the two StringBuilders for the user. (Remember one had the first three characters of the ones that pass in the order they were put in, and the second one has the ones that failed in the order of last entered.) You can do this in Labels, a Listbox, Messagebox, or other controls. It is up to you how you display them for the user.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!