制作唱片节目,我有点卡住了。
program myMusicPlayer;
uses TerminalUserInput, SysUtils;
type
genreType = (Comedy, Punk, Metal);
album = record
albumName : String;
artistName : String;
genre : genreType;
tracks : array [0..4] of String;
location: array [0..4] of String;
end;
function readGenre(prompt: String): genreType;
var
val : Integer;
begin
WriteLn('1 - Comedy');
WriteLn('2 - Punk');
WriteLn('3 - Metal');
val := ReadInteger(prompt);
while ((val < 1) or (val > 3)) do
begin
WriteLn('Please enter a value between 1 & 3');
val := ReadInteger(prompt);
end;
result := genreType(val-1);
end;
function readAlbum(const alb : album): album;
var
i: Integer;
begin
result.albumName := ReadString('Enter album name here: ');
result.artistName := ReadString('Enter artist name here: ');
result.genre := readGenre('Enter genre here: ');
for i := 0 to 4 do
begin
result.tracks[i] := ReadString('Enter track list here: ');
end;
for i := 0 to 4 do
begin
result.location[i] := ReadString('Enter file location here: ');
end;
end;
procedure printAlbum(const toPrint: album);
var
i : Integer;
begin
WriteLn('Album title: ', toPrint.albumName);
WriteLn('Artist name: ', toPrint.artistName);
WriteLn('Genre: ', toPrint.genre);
for i := 0 to 4 do
begin
WriteLn('Track ', i, ' is: ', toPrint.tracks[i]);
WriteLn('File ', i, ' location is: ', toPrint.location[i]);
end;
end;
此过程“runAlbum”正在发生问题,我尝试使用此功能,以便用户可以选择1到4之间的数字来选择他们之前输入的相应曲目。
procedure runAlbum(prompt: String; min, max: Integer);
var
result : Integer;
begin
result := ReadInteger(prompt);
while ((result < min) or (result > max)) do
begin
WriteLn('Please select a track between', min, ' and ', max, ' to play:
');
result := ReadInteger(prompt);
end;
end;
但是我不清楚我需要在runAlbum旁边的括号中输入什么参数来运行程序,现在我尝试的所有内容都运行错误“为”runAlbum“设置的参数数量错误”
procedure Main();
var
newAlbum : album;
begin
newAlbum := readAlbum(newAlbum);
printAlbum(newAlbum);
runAlbum();
end;
begin
Main();
end.
答案 0 :(得分:4)
当您致电runAlbum
时,您必须为其声明中指定的每个参数提供值(即参数),即Prompt
,min
和max
。目前,您没有证明任何参数值,因为您的呼叫中有空括号。
所以你应该用类似
的方式来调用它runAlbum(newAlbum.albumName +': enter a track number to play', 0, 99);
当然,值0和99应替换为newAlbum
可用的最低和最高数字。我假设您将能够找出如何从专辑数据中提供相关值。