February 6, 2018
Deadlines: You don’t have to complete this lab before the first exam, but doing so would definitely help you. You have to complete it before the 20th of February.
This time, you will have to start your project “from scratch” and shouldn’t try to edit a previous program.
.cs
files opened and displayed in the Solution Explorer: Program.cs
and Circle.cs
.Circle.cs
, of type double
and named radius
. Write a set
and a get
method for this instance variable.Program.cs
, write statements that create a new Circle
object and set its radius to 2.3. Print its radius using the method you defined previously.Math.PI
is a double
holding an approximation of π. In the Main
method of Program.cs
, write a statement that prints its value.Circle.cs
file, add two methods:Main
program, by printing the area and the circumference of the object you created at the previous exercise.double
as argument, and set the value of the radius created to the value given as a parameter. Note that you can’t compile your program anymore. Why?Main
method to make your program complilable again. Instead of the default constructor (that isn’t available anymore), use the constructor you just defined.Main
method so that two objects are created: one using the “no-args” constructor, one using the constructor that takes an argument.Draw the UML diagram for the class you just implemented. Make sure it matches perfectly your implementation.
The following are two independent tasks, to widen your understanding of this class, sharpen your coding skills, and prepare you for the next labs.
Rectangle
project from the previous lab and write three constructors:
Test them, and make sure they have the expected behavior.
Have a look at the Math
class’s specification, at https://docs.microsoft.com/en-us/dotnet/api/system.math?view=netframework-4.7.1 Can you write a statement that prints the result of Min(214, ⌊log(4000⌋)?