0% found this document useful (0 votes)
1K views4 pages

02 Hands-On Activity 1

Uploaded by

Ericka Janelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views4 pages

02 Hands-On Activity 1

Uploaded by

Ericka Janelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

IT1811

Hands-on Activity
Basic Queuing System
Objectives:

At the end of the exercise, the students should be able to:


 Use simple and generic collection in a program;
 Manipulate a program using generic collection methods; and
 Create a hashtable, list, stack, and queue.

Software Requirement:

 One (1) personal computer with pre-installed Windows Operating System


 Visual Studio IDE 2015 or higher

Procedures:

Instructions:
1. Create a queuing program that automatically generates a number once the student clicks the button to
get a number. This program should have two (2) window forms named QueuingForm and
CashierWindowQueueForm. See Figures 1 and 2.

Figure 1. QueuingForm

Figure 2. CashierWindowQueueForm

2. Follow the given design in Figure 1. See Table 1 for the names of the control that contains function.

02 Hands-on Activity 1 *Property of STI


Page 1 of 4
IT1811

Table 1. Forms and Controls


Controls/Forms Name

Button btnCashier

Label lblQueue

Form QueuingForm

Tab le 1. Forms and Controls


*Note: The other label is not required to set the names, only the controls/forms that is needed.

3. Create a class named CashierClass and add the following codes:


private int x;
public static string getNumberInQueue = "";
public static Queue<string> CashierQueue;

public CashierClass(){
x = 10000;
CashierQueue = new Queue<string>();
}
public string CashierGeneratedNumber(string CashierNumber){
x++;
CashierNumber = CashierNumber + [Link]();
return CashierNumber;
}
4. In the first form named QueuingForm, double click the button to create an event named Click.
5. Call CashierClass and declare its variable named cashier. Set the access modifier for the declared
class to private.
Ex. private int x;
6. After the declaration of the variable for CashierClass, initialize the variable cashier inside the
constructor of QueuingForm.
7. After declaring and initializing the code, add the following codes inside the created event of the button
named btnCashier.
[Link] = [Link]("P - ");
[Link] = [Link];
[Link]([Link]);

8. In the second form named CashierWindowQueueForm, add two (2) buttons and a List View control.
See Table 2 for the names of each control.

02 Hands-on Activity 1 *Property of STI


Page 2 of 4
IT1811

Controls/Forms Name

btnRefresh
Button
btnNext

ListView listCashierQueue

Form CashierWindowQueue

Table 2. CashierWindowQueueForm controls

9. Double click the button named btnRefresh to call the event click method and add the code below.
DisplayCashierQueue([Link]);

10. You will notice that the code inside btnRefresh_Click has an error. To remove the error, add the
method below.

public void DisplayCashierQueue(IEnumerable CashierList){


[Link]();
foreach(Object obj in CashierList){
[Link]([Link]());
}
}
*Note: This method is used to display the output on the List View. You can still modify this code for different controls.

02 Hands-on Activity 1 *Property of STI


Page 3 of 4
IT1811

Challenge Exercise:
11. The given code will only add the number in queue and manually refresh the list for new students.
12. For this challenge exercise, write a program that will remove the number that is already done.
13. Make this program automatically refresh the list when there are updates in the queue.
*Note: Use the Timer control for this. See the sample code below for the timer class.
Timer timer = new Timer();
[Link] = (1 * 1000) // 1 sec.
[Link] += new EventHandler(timer1_tick); //timer1_tick represents the name of Tick Event
[Link]();

14. Run the program to check the output.

02 Hands-on Activity 1 *Property of STI


Page 4 of 4

You might also like