Skip to content

Instantly share code, notes, and snippets.

@dz0
Last active October 5, 2016 16:37
Show Gist options
  • Select an option

  • Save dz0/766728e7db751712bc12f41c1286b30a to your computer and use it in GitHub Desktop.

Select an option

Save dz0/766728e7db751712bc12f41c1286b30a to your computer and use it in GitHub Desktop.
using System;
namespace BoxApplication
{
class Box
{
public double length; // Length of a box
public double breadth; // Breadth of a box
public double height; // Height of a box
// Konstruktoriaus funkcija -- suteikia pradines reiksmes
public Box( double a, double b, double c )
{
length = a;
breadth = b;
height = c;
}
//public double getVolume()
//{
// return length * breadth * height;
//}
// savybe vietoj buvusios funkcijos
public double Volume {
get { return length * breadth * height; }
}
// standartine funkcija objekto atvaizdavimui tekstu
public override string ToString()
{
return String.Format("length {1}, breadth {2}, height {3}. Volume: {0}",
Volume, length, breadth , height
);
}
}
class Boxtester
{
static void Main(string[] args)
{
Box Box1 = new Box(5, 6, 7); // Declare Box1 of type Box
Box Box2 = new Box(10, 12, 13); // Declare Box2 of type Box
Box Box3 = new Box(3,2,1); // Declare Box2 of type Box
Console.WriteLine(Box1); // vietoj Box1.getVolume()
Console.WriteLine(Box2);
Console.WriteLine(Box3);
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment