Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED HELP UNDERSTNADING USING C#! using System; namespace Lab_Exercise_3 { class Hidden { private int number; public int GetValue() { return number; } public void

NEED HELP UNDERSTNADING USING C#! using System; namespace Lab_Exercise_3 { class Hidden { private int number; public int GetValue() { return number; } public void SetValue(int initiate) { number = initiate; } } class Program { static void Main(string[] args) { int number1 = 0; int number2 = 0; Random rnd = new Random(); int randomNumber = rnd.Next(100); Hidden unknown = new Hidden(); unknown.SetValue(randomNumber); Console.WriteLine("!!! Guess my number !!! "); Console.WriteLine("You have two chances to guess my number from the range 0 .. 99 "); Console.Write("Guess my number in the first attempt: "); number1 = int.Parse(Console.ReadLine()); if (number1 > unknown.GetValue()) { Console.WriteLine($"Your number {number1} is greater than mine by {number1 - unknown.GetValue()}"); } if (number1  

image text in transcribed

Your task in this Lab Exercise is to practice simple manipulation of objects combined with prompting users for input, getting input in from the users, storing user input in variables, using if statements. This is a 'code rewriting'-type exercise. You'll start with source code that we provide, and you make all necessary alterations. Requirements Application o Open Visual Studio o Create a new project with the name Lab Exercise_3 and the same solution name Lab_Exercise_3 o Copy/paste the content of the provided Lab_Exercise_3 text file completely replacing the content of predefined by Visual Studio default solution. o Your main tasks are: . execute the predefined solution, rewrite the content of class Hidden with the private instance integer variable number such that the public methods SetValue and GetValue are replaced with a public Number property (see figure 4.6 in Chapter 4 slides), rewrite the rest of the code to reflect alterations in class Hidden, ensure your final solution will save, build and run successfully

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

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions