StartprogrammingusingObjectPascal:RestaurantProgramUsingFunctions

From 흡혈양파의 번역工房
Revision as of 10:29, 26 July 2012 by Onionmixer (talk | contribs) (SPOP 함수를사용한식당프로그램 페이지 추가)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

함수를 사용한 식당 프로그램

procedure Menu;
begin
    Writeln('Welcome to Pascal Restaurant. Please select your order');
    Writeln('1 – Chicken          (10$)');
    Writeln('2 – Fish                  (7$)');
    Writeln('3 – Meat                (8$)');
    Writeln('4 - Salad               (2$)');
    Writeln('5 - Orange Juice (1$)');
    Writeln('6 – Milk                  (1$)');
    Writeln;
end;

function GetOrder(AName: string; Minutes, Price: Integer): Integer;
begin
    Writeln('You have ordered : ', AName, ', this will take ',
         Minutes, ' minutes');
    Result := Price;
end;

// Main application
var
    Selection: Char;
    Price: Integer;
    Total: Integer;
begin
    Total := 0;
    repeat
        Menu;
        Write('Please enter your selection: ');
        Readln(Selection);
        case Selection of
            1: Price := GetOrder('Chicken', 15, 10);
            2: Price := GetOrder('Fish', 12, 7);
            3: Price := GetOrder('Meat', 18, 8);
            4: Price := GetOrder('Salad', 5, 2);
            5: Price := GetOrder('Orange juice', 2, 1);
            6: Price := GetOrder('Milk', 1, 1);
            x, X: Writeln(Thanks);
            else
            begin
                Writeln('Wrong entry');
                Price:= 0;
            end;
        end;

        Total := Total + Price;
    until (Selection = x) or (Selection = X);
    Writeln(Total price                   = ,Total);
    Write('Press enter key to close');
    Readln;
end.