$50
In this part of the project, you will implement the number guessing services and number guessing games using different techniques. You are given the class definition below as the basic functions required in the number guessing services.
public class NumberGuess {
public int SecretNumber(int lower, int upper) { DateTime currentDate = DateTime.Now; int seed = (int)currentDate.Ticks; Random random = new Random(seed); int sNumber = random.Next(lower, upper); return sNumber;
}
public string checkNumber(int userNum, int SecretNum) { if (userNum == SecretNum) return "correct"; else if (userNum SecretNum) return "too big"; else return "too small";
}
}
1. Based on the above given class, write a WCF .svc service with two operations on localhost of .Net IIS Express server. You may want to review Text Section 3.2 before completing this assignment. [10 points]
2. Create an ASP .Net Windows Forms Application to consume the .svc service in question 1. Visual Studio 2019 and 2017 project options are shown in Figure 1(a) and (b), respectively.
(a) Search for Windows Forms template in Visual Studio 2019
(b) Choose Windows Forms template in Visual Studio 2017
Figure 1. Creating a Windows Forms App project in VS 2019(a) and VS 2017(b)
You can host the service and the application on localhost or IIS Express. The application GUI must contain at least the following items, as shown in Figure 2. You can add additional components in your
design. [15 points]
Figure 2. Number Guessing Game Basic GUI Design
• The first two textboxes are used for a player to enter the lower and upper limits (integers) of the random number to be generated;
• The code behind the button “Generate a Secret Number” will generate a secret number and save it as a state;
• The last textbox allows the player to enter an integer to make a guess of the secret number.
• A label (attempts) that displays how many attempts have been made after a secret number is generated.
• A label (The number is) that displays if the given number is too small, too big, or a correct guess.
3. Create a self-hosing service to implement the NumberGuess class, with the SecretNumber and CheckNumber as operations. The program must include the service and the hosting code. [20 points]
4. Write a console application to call the self-hosting service and to display the output of the service. The application must use svcutil.exe to generate the proxy. [5 points]
Assignment 1 submission requirement:
Questions 1 and 2 must be in one solution, and questions 3 and 4 must be in another solution. Each solution folder must contain all the files. Put the two solution folders into another folder. Zip the folder (a single file) for submission. Testing results (with screenshots) must be submitted in a Word document or in PDF.
You must indicate in the document the Visual Studio version (2017 or 2015) and the template that you use, so that the TA can use the same tools to test your program.
Assignment 2 Advanced Service and Application Architecture
In this assignment, you will continue to work on the project that you created in assignment 1.
5. Re-implement the NumberGuess service as a RESTful service. Host the service on IIS Express server. For each service operation in the service developed in the question above, add UriTemplate in the attribute [WebGet], so that the service operation names are not exposed to the callers of the service.
[20 points]
6. Choose one of the following assignment options to implement your application architecture that calls your service. [30 points]
6.1 Option 1: Create an MVC Web Application (Please read Text Section 5.8.2 and Lecture 1-6 slides) to consume the RESTful service in question 5. You must create at least one asynchronous call to access the service using BeginGetResponse and a callback function. Please read text section 7.3.7 for an example. The following diagrams in Figure 3 and Figure 4 show some of the steps of creating a MVC Web application in VS 2017. If you use a different version, you may need to use different variation of the steps following MSDM documents.
(a) Use Visual Studio 2019
Figure 3. Creating a Web App project in VS 2019(a) and in VS 2017(b)
You may need to download .Net Core 2.0, as shown in the following diagram.
You can host the application on IIS Express. The application GUI must contain at least the items that are shown in Figure 2.
6.2 Option 2: Create an HTML 5 Web Application to consume the RESTful service in question 5. You are required to create graphic user interface. Creating animation is optional.
In this option, you will read additional reference materials to learn HTML 5 programming model and HTML 5 graphics libraries. There is a short introduction in Text Section 4.6.5. A sample code is given that shows the creation of graphic user interface and animation in HTML 5.
You can use different platforms to create HTML Web application. You can use Visual Studio or use a Java environment. For example, you can follow the tutorial given at the link:
https://netbeans.org/kb/docs/webclient/html5-gettingstarted.html
You can also use Visual Studio to implement this question. Choose New Project…, Web, and then Single Page Application template: