Advertisement
abasar

Song.cs

Feb 21st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. //program.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10.     class Program
  11.     {
  12.         static double Memuza(Song song1, Song song2)
  13.         {
  14.             return (double)(song1.GetLength() + song2.GetLength()) / 2;
  15.         }
  16.  
  17.         static void Main(string[] args)
  18.         {
  19.             Song song1 = new Song(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));
  20.             Song song2 = new Song(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));
  21.             Console.WriteLine(Memuza(song1, song2));
  22.             song2.SetLength(song1.GetLength()/2);
  23.             Console.WriteLine(Memuza(song1, song2));
  24.         }
  25.     }
  26. }
  27. //song.cs
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Linq;
  31. using System.Text;
  32. using System.Threading.Tasks;
  33.  
  34. namespace ConsoleApplication1
  35. {
  36.     class Song
  37.     {
  38.         private int length, siduri;
  39.  
  40.         public Song(int length, int siduri)
  41.         {
  42.             this.length = length;
  43.             this.siduri = siduri;
  44.         }
  45.  
  46.         public int GetLength()
  47.         {
  48.             return this.length;
  49.         }
  50.  
  51.         public int GetSiduri()
  52.         {
  53.             return this.siduri;
  54.         }
  55.  
  56.         public void SetLength(int length)
  57.         {
  58.             this.length = length;
  59.         }
  60.  
  61.         public void SetSiduri(int siduri)
  62.         {
  63.             this.siduri = siduri;
  64.         }
  65.  
  66.         public string ToString()
  67.         {
  68.             return "length is " + this.length + ", siduri is " + this.siduri;
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement