C
C
carbanak012021-03-18 17:20:40
OOP
carbanak01, 2021-03-18 17:20:40

Why does PascalABC.NET throw an error when creating an object?

Hello!
When completing a task in Pascal, an error appears: 6053604ef1dc0430004492.png

This is an OOP task, just throw in the condition:
Describe the "Travel Bureau" object with an indication of its methods: country of travel, duration of rest, date of departure, excursions (include or refuse), the cost of excursions, the cost of a tour ( excluding excursions), the number of tourists, the cost of travel. Implement the methods declared in the object.

Here is the code that I wrote following the tutorial:

type Turburo = object
    country, date:string;
   duration, ex_price, putevka, kol_tourists, total_price: integer;
   ex: boolean;
   procedure create;
end;

procedure Turburo.create;
var is_ex:integer;
begin
    write('Страна: ');
    readln(country);
    write('Длительность отдыха: ');
    readln(duration);
    write('Дата отправления: ');
    readln(date);
    write('Включать экскурсии?(0-нет, 1-да):');
    readln(is_ex);
    if is_ex = 1 then begin
                                  ex := true;
                                  write('Стоимость экскурсии: ');
                                  readln(ex_price);
                               end
                       else ex:=false;
    write('Стоимость путевки(без учёта экскурсии): ');
    readln(putevka);
    write('Кол-во туристов: ');
    readln(kol_tourists);

    total_price:= ex_price + putevka;
    write('Стоимость путешествия:', total_price);
end;

var tur:Turburo;

begin
tur.create;
end.


Judging by the manual, this error should not be, since the syntax is correct, I don’t understand why the PascalABC.NET compiler is so angry, but the online version https://www.onlinegdb.com/online_pascal_compiler is not.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2021-03-18
@carbanak01

Because you have a newer pascal, not a turbo pascal.
You need to use the word class, not object

type Turburo = class
     country, date:string;
   duration, ex_price, putevka, kol_tourists, total_price: integer;
   ex: boolean;
   procedure create;
end;

M
mkone112, 2021-03-18
@mkone112

Because you met 'country' and expected ';'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question