1 / 1 / 0
Регистрация: 18.09.2009
Сообщений: 24
1

ООП, графика. Не пойму в чем ошибки

16.12.2009, 13:36. Показов 1091. Ответов 3
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Всем добрый день. Есть программа, никак не могу понять на что ругается компилятор. Пишет следующее:
(11,25) function header doesn't match any method of this class "constructor Locationn.init(Smallint, Smallint);"
(52,19) function header doesn't match any method of this class "Point.Moveto;"
(57,11) Identifier not found "newX"
(58,11) Identifier not found "newY"
Текст программы:
Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
program lab4;
uses crt,graph;
type Locationn = object
          x,y :integer;
          procedure init (initX,initY :integer);
          function getx: integer;
          function gety: integer;
          destructor done;
        end;
 
  Constructor Locationn.Init (initX,initY :integer);
    Begin
      X:=InitX;
      Y:=InitY
    End;
 
  Destructor Locationn.Done;
    Begin
    End;
 
  Function Locationn.GetX:integer;
    Begin
      GetX:=x;
    End;
 
  Function Locationn.GetY:integer;
    Begin
      GetY:=y;
        End;
 
 {===================================================================}
 
 type Point = object (Locationn)
          Visible: boolean;
          procedure Show; virtual;
          procedure Hide; virtual;
          procedure Moveto (newX,newY :integer);
     end;
 
  Procedure Point.Show;
    Begin
      Putpixel(x,y,Getcolor);
      Visible:=true
    End;
 
  Procedure Point.Hide;
    Begin
      Putpixel(x,y,GetBkColor);
      Visible:=false
    End;
 
  Procedure Point.Moveto;
        Var TempVisible:boolean;
    Begin
          TempVisible:=visible;
      If TempVisible then Hide;
      X:=newX;
      Y:=newY;
      If TempVisible then Show;
        End;
 
  {===================================================================}
 
  type Tkrest = object (Point)
        private
            radius : integer;
            timeDelay : integer;
        public
            procedure setRadius(pradius : integer);
            function getRadius : integer;
            procedure setTimeDel(ptime : integer);
            function getTimeDel : integer;
            procedure drawKrest;
            constructor init;
         end;
 
  constructor Tkrest.init;
      begin
      end;
 
  procedure Tkrest.setRadius(pradius : integer);
    begin
      if(pradius <= 0) then pradius := 50;
      radius := pradius;
    end;
 
  function Tkrest.getRadius : integer;
    begin
      getRadius := radius;
    end;
 
  procedure Tkrest.setTimeDel(ptime : integer);
    begin
     if(ptime <= 0) then ptime := 1000;
     timeDelay := ptime;
    end;
 
  function Tkrest.getTimeDel : integer;
    begin
     getTimeDel := timeDelay;
    end;
 
  procedure Tkrest.drawKrest;
  var gd,gm,x1,y1,x2,y2,x3,y3,x4,y4,r,d,i,j : integer;
      ch : char;
begin
    gd := 0;
    initgraph(gd, gm, '');
    i := 1;
    j := 90;
    setcolor(5);
    setlinestyle(1, 0, 3);
 
    repeat
        x1 := round(getRadius * cos(i * pi / 180)) + getmaxx div 2;
        y1 := round(getRadius * sin(i * pi / 180)) + getmaxy div 2;
        x2 := round(getRadius * cos(i * pi / 180 + pi)) + getmaxx div 2;
        y2 := round(getRadius * sin(i * pi / 180 + pi)) + getmaxy div 2;
        x3 := round(getRadius * cos(j * pi / 180)) + getmaxx div 2;
        y3 := round(getRadius * sin(j * pi / 180)) + getmaxy div 2;
        x4 := round(getRadius * cos(j * pi / 180 + pi)) + getmaxx div 2;
        y4 := round(getRadius * sin(j * pi / 180 + pi)) + getmaxy div 2;
        line(x1, y1, x2, y2);
        line(x3, y3, x4, y4);
        delay(getTimeDel);
        cleardevice;
        if(i < 360) then
            inc(i)
        else
            i := 1;
        if(j < 450) then
            inc(j)
        else
            j := 90;
        if(keypressed) then
            ch := readkey;
    until(ch = #27);
end;
 
  {===================================================================}
 
  var krest : Tkrest;
      r,d : integer;
BEGIN
    clrscr;
    krest.init;
    write('Введите радиус: ');
    readln(r);
    krest.setRadius(r);
    write('Введите задержку: ');
    readln(d);
    krest.setTimeDel(d);
    krest.drawKrest;
END.
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
16.12.2009, 13:36
Ответы с готовыми решениями:

Не пойму в чем ошибка при использовании ООП
Подскажите пожалуйста, почему в этом коде VC++ выдает ошибку: Error: &quot;Friends::Friends(const char*...

Никак не пойму ООП
public class Main { static Cat cat = new Cat(); static People people = new People(); ...

Изучаю ООП не пойму почему не выводит
Есть код: &lt;?php class Member { private $username; public function __construct(...

не пойму что за ошибки
procedure TForm1.Button6Click(Sender: TObject); var i: integer; begin WITH...

3
Тимуровец
445 / 285 / 50
Регистрация: 10.09.2009
Сообщений: 963
16.12.2009, 13:50 2
procedure init (initX,initY :integer);
Constructor Locationn.Init (initX,initY :integer);

procedure Moveto (newX,newY :integer);
Procedure Point.Moveto;

Теперь видите?
1
1856 / 1178 / 190
Регистрация: 27.03.2009
Сообщений: 4,558
16.12.2009, 13:53 3
Цитата Сообщение от random7 Посмотреть сообщение
procedure Moveto (newX,newY :integer);
а как вызывается
Цитата Сообщение от random7 Посмотреть сообщение
Procedure Point.Moveto;
1
1 / 1 / 0
Регистрация: 18.09.2009
Сообщений: 24
16.12.2009, 15:18  [ТС] 4
Товарищи, помогите еще с одним вопросом пожалуйста. Нужно чтобы в программе использовались виртуальные методы (позднее связывание). Где в программе это можно вставить, не разберусь никак...
Чуть переделанный текст программы:
Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
program lab4;
uses crt,graph;
type Locationn = object
          x,y :integer;
          constructor init (initX,initY :integer);
          function getx: integer;
          function gety: integer;
          destructor done;
        end;
 
  Constructor Locationn.Init (initX,initY :integer);
    Begin
      X:=InitX;
      Y:=InitY
    End;
 
  Destructor Locationn.Done;
    Begin
    End;
 
  Function Locationn.GetX:integer;
    Begin
      GetX:=x;
    End;
 
  Function Locationn.GetY:integer;
    Begin
      GetY:=y;
        End;
 
 {===================================================================}
 
 type Point = object (Locationn)
          Visible: boolean;
          procedure Show; virtual;
          procedure Hide; virtual;
          procedure Moveto (newX,newY :integer);
     end;
 
  Procedure Point.Show;
    Begin
      Putpixel(x,y,Getcolor);
      Visible:=true
    End;
 
  Procedure Point.Hide;
    Begin
      Putpixel(x,y,GetBkColor);
      Visible:=false
    End;
 
  Procedure Point.Moveto (newX,newY :integer);
        Var TempVisible:boolean;
    Begin
          TempVisible:=visible;
      If TempVisible then Hide;
      X:=newX;
      Y:=newY;
      If TempVisible then Show;
        End;
 
  {===================================================================}
 
  type Tkrest = object (Point)
        private
            radius : integer;
            timeDelay : integer;
        public
            procedure setRadius(pradius : integer);
            function getRadius : integer;
            procedure setTimeDel(ptime : integer);
            function getTimeDel : integer;
            procedure drawKrest;
            constructor init;
         end;
 
  constructor Tkrest.init;
      begin
      end;
 
  procedure Tkrest.setRadius(pradius : integer);
    begin
      if(pradius <= 0) then pradius := 50;
      radius := pradius;
    end;
 
  function Tkrest.getRadius : integer;
    begin
      getRadius := radius;
    end;
 
  procedure Tkrest.setTimeDel(ptime : integer);
    begin
     if(ptime <= 0) then ptime := 1000;
     timeDelay := ptime;
    end;
 
  function Tkrest.getTimeDel : integer;
    begin
     getTimeDel := timeDelay;
    end;
 
  procedure Tkrest.drawKrest;
  var gd,gm,x1,y1,x2,y2,x3,y3,x4,y4,r,d,i,j : integer;
      ch : char;
begin
    i := 1;
    j := 90;
    setcolor(5);
    setlinestyle(1, 0, 3);
 
    repeat
        x1 := round(getRadius * cos(i * pi / 180)) + getmaxx div 2;
        y1 := round(getRadius * sin(i * pi / 180)) + getmaxy div 2;
        x2 := round(getRadius * cos(i * pi / 180 + pi)) + getmaxx div 2;
        y2 := round(getRadius * sin(i * pi / 180 + pi)) + getmaxy div 2;
        x3 := round(getRadius * cos(j * pi / 180)) + getmaxx div 2;
        y3 := round(getRadius * sin(j * pi / 180)) + getmaxy div 2;
        x4 := round(getRadius * cos(j * pi / 180 + pi)) + getmaxx div 2;
        y4 := round(getRadius * sin(j * pi / 180 + pi)) + getmaxy div 2;
        line(x1, y1, x2, y2);
        line(x3, y3, x4, y4);
        delay(getTimeDel);
        cleardevice;
        if(i < 360) then
            inc(i)
        else
            i := 1;
        if(j < 450) then
            inc(j)
        else
            j := 90;
        if(keypressed) then
            ch := readkey;
    until(ch = #27);
end;
 
  {===================================================================}
  Type World = object
      GMode :integer;
      GDriver :integer;
      procedure Initworld;
      procedure Endworld;
    End;
 
  procedure World.Initworld;
        begin
           Gdriver := 0;
           initgraph(GDriver,GMode,'')
        end;
 
  procedure World.Endworld;
    begin
      Closegraph;
    end;
 
  {===================================================================}
 
  var krest : Tkrest;
      r,d : integer;
      w : World;
BEGIN
    clrscr;
    krest.init;
    write('Введите радиус: ');
    readln(r);
    krest.setRadius(r);
    write('Введите задержку: ');
    readln(d);
    w.Initworld;
    krest.setTimeDel(d);
    krest.drawKrest;
    w.Endworld;
END.
0
16.12.2009, 15:18
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
16.12.2009, 15:18
Помогаю со студенческими работами здесь

не пойму вывод ошибки
#include &quot;model_main.h&quot; #include &quot;ui_model_main.h&quot; Model_Main::Model_Main(QWidget *parent) : ...

Не пойму причину ошибки!
Здравствуйте! В данном куске кода у меня должен удаляться выделенный элемент в CheckListBox1 и в...

не пойму причину ошибки
вот прога, надо по названию продукта, выводить о нем инфу, после первой строки read (f, .. ..пишет...

Возникают 2 ошибки, не пойму из-за чего
const Cons = ; type TChars = array of Char; procedure ExcludeStr(var m: TChars; const s: String);...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru