שפת C

מתוך ויקיספר, אוסף הספרים והמדריכים החופשי
קפיצה לניווט קפיצה לחיפוש
           private string  name;             // Name of song
           private string  performer;      // Song performer         
           private int  length;                  // song length in seconds
           public Song(string name, string performer, int length)
           {
                   this.name = name;
                   this.performer = performer;
                   this.length = length;
           }
           public Song(Song song1)

{ this.name = song1.GetName(); this.performer = song1.GetPerformer(); this.length = song1.GetLength(); }

           public string GetName()
           {
                   return this.name;
           } 
           public string GetPerformer()
           {
                   return this.performer;
           }
           public int GetLength()
           {
                   return this.length;
           }
   public void SetName(string name)
           {       
  		this.name = name;
           }
   	     public void SetPerformer(string performer)
           {       
  		this.performer = performer;             
           }
           public void SetLength(int length)
           {        
		   	this.length = length;         
           }
          public void IncreaseLength(int sec)
          {     
        this.length += sec;          
          }
           public void DecreaseLength(int sec)
           {      
 			 this.length -= sec;   
            }
           public string Category()
           {
                if (this.length< 120)
                        return "short";
                if (this.length > 240)
                        return "long";
                 return "average";
           }
          public string ToString()
          {
                  return "The song name is: " +this.name+" the preformer is: " + 								this.performer+ " the song length in seconds is: " + length;                        
         }