using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFirstConsoleApp.day2.examples
{
class TestBox
{
static void Main()
{
Box ups, fedEx;
ups = new Box();
fedEx = new Box();
ups.length = 10;
ups.width = 5;
double total = ups.CalculateArea(3, 4);
fedEx.length = 7;
fedEx.width = 5;
total += fedEx.CalculateArea(5, 6);
Console.WriteLine("total area = " + total);
Console.ReadLine();
}
}
}
****************
************
**************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFirstConsoleApp.day2.examples
{
class Box
{
public int length;
public int width;
public double CalculateArea(int length, int width)
{
double area = length * width;
// double area = this.length * this.width;
Console.WriteLine("Area = " + area);
return area;
}
}
}
No comments:
Post a Comment