using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
PhysicalObject ph = new PhysicalObject();
ph.Weight = double.Parse(Console.ReadLine());
ph.Veloum = double.Parse(Console.ReadLine());
ph.ifdrop();
Console.ReadKey();
}
}
class PhysicalObject
{
private double weight;
private double veloum;
public double Weight
{
get { return weight; }
set { weight = value; }
}
public double Veloum
{
get { return veloum; }
set { veloum = value; }
}
public double midu
{
get { return weight / veloum; }
}
public void ifdrop()
{
if (weight / veloum == 1)
{
Console.WriteLine("此物体会漂浮!");
}
else if (weight / veloum >= 1)
{
Console.WriteLine("此物体会下沉!");
}
else
{
Console.WriteLine("此物体会下沉!");
}
}
}
}
c#实验5.2:物体类
最新推荐文章于 2023-12-29 11:50:31 发布