---
# System prepended metadata

title: Lab5-2

---

## Create class **Hemisphere**. 

- The class has an field **radius** ( r )  which defaults to 1. 

- It has property **Radius** for radius. 
    - Code Examples 範例:
        ```csharp 
        public double Radius
        {
            get
            {
                return radius;
            }
            set
            {
                . . . 
            }
        }
        ```
    - The **set** accessor should verify that **radius** is a floating - number greater than 0.0 and less than 12.0. 


        > Hint: If radius is out of range, you should write this:
        ```csharp
        throw new ArgumentOutOfRangeException(nameof(value), value, $"{nameof(value)} must > 0.0 and < 12.0");
        ```
- It has methods that calculate **Volume** ($\frac{2}{3}\cdot π\cdot r^3$), **CurvedSurfaceArea** ($2\cdot π\cdot r^2$) and **TotalSurfaceArea** ($3\cdotπ\cdot r^2$) of the hemisphere.
    > Hint: use **Math.PI** for π
- - -
### **Write a program to test class Hemisphere**.

- **Test Code Example**: 
    ```csharp
    Hemisphere h = new Hemisphere(5);

    Console.WriteLine(h.Volume());
    Console.WriteLine(h.CurvedSurfaceArea());
    Console.WriteLine(h.TotalSurfaceArea());
    ```
