第1个回答 2007-01-15
program SS;
//Created By Chely
// 2007-01-15
{$APPTYPE CONSOLE}
uses
SysUtils,
Math;
type
TExamMGR = class
private
FScore: Integer;
procedure ShowTitle();
procedure ShowScore();
procedure ShowEndTip();
public
constructor Create();
procedure BeginExam();
property Score: Integer read FScore;
end;
var
ExamMGR: TExamMGR;
{ TExamMGR }
procedure TExamMGR.BeginExam;
var
I: Byte;
V1,V2,R: Integer;
begin
//Todo: Flow For ExamMGR.BeginExam;
//Step1: Show Title;
//Step2: Begin
//Step3: ShowScore;
//Step4: Show Query Infos;
Self.ShowTitle;
for I := 0 to 9 do
begin
Randomize();
V1 := RandomRange(0,1000);
V2 := RandomRange(0,1000);
Writeln(I + 1,'(th) Test: ',V1,' + ',V2,' = ');
Readln(R);
if R = V1 + V2 then
Inc(Self.FScore,1);
end;
Self.ShowScore;
Self.ShowEndTip;
end;
constructor TExamMGR.Create;
begin
inherited;
Self.FScore := 0;
end;
procedure TExamMGR.ShowEndTip;
var
R: String;
begin
Writeln('You Wanna Try Again?');
Writeln('Press "Y" 2 Try Again');
Readln(R);
if LowerCase(R) = 'y' then
Self.BeginExam;
end;
procedure TExamMGR.ShowScore;
begin
Writeln('Yer Final Score Is: ',Self.Score);
end;
procedure TExamMGR.ShowTitle;
var
tmp: String;
begin
Writeln('You Gotta Finish 10 Test,Press Any Key 2 Continue...');
Readln(tmp);
end;
begin
ExamMGR := TExamMGR.Create;//Build TExamMGR Instance;
ExamMGR.BeginExam;
ExamMGR.Free;//Recircle System Resource;
end.
//运行Delphi,创建控制台工程,清除所有框架代码,然后将上面代码粘贴上,Ctrl + F9编译即可使用.
第2个回答 2007-01-15
program ss(input,output);
var
a,b,c,i,s:integer;
begin
randomize;
s:=0;
for i:=1 to 10 do
begin
a:=random(1000);
b:=random(1000);
writeln(str(a),'+',str(b));
read(c);
if a+b=c then
begin
s:=s+10;
writeln('correct');
end
else
writeln('wrong');
end;
end;
writeln('total=',s);
end.本回答被提问者采纳