我不太了解数组,我需要创建“歌曲数组”类型的变量,然后将其初始化为新的数组,以便它可以存储对Songs的4个引用。然后我该如何创建一个循环,该循环将运行足够的时间来填充数组,同时调用InputSOngDetails()方法并将返回值存储在该方法中?
namespace Songs
{ 班级计划 { 静态void Main(string [] args){
InputSongDetails();
}
static Song InputSongDetails()
{
Console.WriteLine("What is the name of your song");
string name = Console.ReadLine();
Console.WriteLine("What is the artists name");
string artist = Console.ReadLine();
int records;
Console.WriteLine("How many records did it sell");
while (!int.TryParse(Console.ReadLine(), out records) || records < 0)
{
Console.WriteLine("That is not valid please enter a number");
}
return new Song(name, artist, records);
}
}
}
如果需要,这是我的歌曲课程
命名空间歌曲 { 类歌 { 字符串名称; 弦乐师 int copySold;
public Song(string name, string artist, int copiesSold)
{
this.name = name;
this.artist = artist;
this.copiesSold = copiesSold;
}
public Song()
{
}
public string GetArtist()
{
return artist;
}
public string GetDetails()
{
return $"Name: {name} Artist: {artist} Copies Sold: {copiesSold},";
}
public string GetCertification()
{
if (copiesSold<200000)
{
return null;
}
if (copiesSold<400000)
{
return "Silver";
}
if (copiesSold<600000)
{
return "gold";
}
return "Platinum";
}
}
}
答案 0 :(得分:0)
将宽度/高度声明为100%,但使用max-width / max-height限制为所需的尺寸。
<iframe style="width: 100%; height: 100%; max-width: 700px; max-height: 400px"></iframe>