// Sample Solution
using System;
namespace ArrayLength
{
class Program
{
static void Main(string[] args)
{
string[] summerStrut;
summerStrut = new string[] { "Juice", "Missing U", "Raspberry Beret", "New York Groove", "Make Me Feel", "Rebel Rebel", "Despacito", "Los Angeles" };
PrintArray(summerStrut);
CheckPlaylist(summerStrut);
Array.Resize(ref summerStrut, 9);
summerStrut[8] = "Love Soon";
PrintArray(summerStrut);
CheckPlaylist(summerStrut);
Array.Resize(ref summerStrut, 6);
PrintArray(summerStrut);
CheckPlaylist(summerStrut);
}
static void CheckPlaylist(string[] summerStrut)
{
if(summerStrut.Length == 8){
string playListName = nameof(summerStrut);
Console.WriteLine($"{playListName} Playlist is ready to go!");
} else if(summerStrut.Length > 8){
Console.WriteLine("Too many songs!");
} else {
Console.WriteLine("Add some songs!");
}
Console.WriteLine();
}
static void PrintArray(string[] summerStrut){
int count = 1;
foreach(string i in summerStrut){
Console.Write($"{count}. {i} ");
count++;
}
Console.WriteLine();
}
}
}
No comments:
Post a Comment