Advertisement
Shirai

Simple Example Class and constructor

Oct 1st, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace NiceTry
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("----Nhap vao nguyen lieu va km-------");
  14.             Console.Write("Nguyen lieu : ");
  15.             int nguyenlieu = Convert.ToInt32(Console.ReadLine());
  16.             Console.Write("Km : ");
  17.             int km = Convert.ToInt32(Console.ReadLine());
  18.             xe abc = new xe(nguyenlieu,km);
  19.             Console.WriteLine("So nguyen lieu can su dung : {0}", abc.tieuthu());
  20.             Console.ReadKey();
  21.         }
  22.     }
  23.     class xe
  24.     {
  25.         public xe()
  26.         {
  27.  
  28.         }
  29.         public int nhienlieu { get; set; }
  30.         public int km { get; set; }
  31.         public xe(int nhienlieu,int km)
  32.         {
  33.             this.nhienlieu = nhienlieu;
  34.             this.km = km;
  35.         }
  36.         public long tieuthu()
  37.         {
  38.             return (Convert.ToInt64(this.nhienlieu * this.km));
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement