using System;
public class Student
{
private int _course;
public string FirstName { get; set; }
public string FamilyName { get; set; }
public int Course
{
get { return _course; }
set
{
if (value < 1 || value > 4)
throw new ArgumentOutOfRangeException(nameof(value), "Need to be 1-4");
_course = value;
}
}
public string GetInfo()
{
string yearSuffix = Course == 1 ? "st" : Course == 2 ? "nd" : Course == 3 ? "rd" : "th";
return $"{FamilyName}{FirstName} , {Course}{yearSuffix} year";
}
}
public class Theromometer
{
private double _celsius;
public double Celsius
{
get { return _celsius; }
set
{
if (value < -273.15)
throw new ArgumentException("Cannot be below zero");
_celsius = value;
}
}
public double Fahrenheit
{
get { return Celsius * 9 / 5 + 32; }
}
}
public class Book
{
public int Pages { get; set; }
public int Year { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public Book() : this("Untitled", "Unknown", 2000, 1)
{
}
public Book(string title, string author) : this(title,author,2000,1)
{
}
public Book(string title, string author, int pages, int year)
{
Title = title;
Author = author;
Pages = pages;
Year = year;
}
}
public class Rectangle
{
private double _width;
private double _height;
public double Width
{
get { return _width; }
set
{
if (value < 0) throw new ArgumentException("Greater than 0");
_width = value;
}
}
public double Height
{
get { return _height; }
set
{
if (value < 0) throw new ArgumentException("Greater than 0");
_height = value;
}
}
public double Area => Width * Height;
public double Perimeter => 2 * (Width * Height);
public Rectangle(double width, double height)
{
_width = width;
_height = height;
}