Pascal/Turbo Pascal - ramon necesito ayuda con un jercicio con lazarus/pascal

 
Vista:

ramon necesito ayuda con un jercicio con lazarus/pascal

Publicado por jorge giron (2 intervenciones) el 22/02/2013 01:44:58
una biblioteca necesita sistematizar el registro de los libros, teniendo en cuenta los siguientes datos: código, titulo del libro, el libro, editorial, año de edición. todos los libros se pueden dar en prestamos a los estudiantes, el libro en su registro debe tener un campo que deben tener el
registrar libro
consultar libro (mostrar todos sus datos)
mostrar todos los registros de los libros.
tenga en cuenta que un libro que este prestado no se puede volver a prestar, para ello el libro tiene que estar disponible y que no se puede registrar mas de un libro con el mismo codigo de libro.
al registrar un libro este automáticamente esta disponible.

gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

ramon necesito ayuda con un jercicio con lazarus/pascal

Publicado por ramon (2158 intervenciones) el 22/02/2013 18:48:18
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
{A ver si esto ayuda}
 
 program biblioteca;
 uses
    crt;
 type
    libro = record
             titulo : string[100];
             autor  : string[200];
          editorial : string;
          fechaedit : string[10];
             estado : boolean;
          end;
 
   registros = record
       fech_acqui : string[10];
           codigo : longint;
          ellibro : libro;
        end;
 
   var
     datos : registros;
     f : file of registros;
 
 
    function rastreacodigo(c : longint) : boolean;
    var
       ii : longint;
       enco : boolean;
    begin
        assign(f,'registro.dat');
     {$I-} reset(f); {$I+}
        if ioresult <> 0 then
        begin
           exit;
        end
     else
        begin
           ii := 0;
           enco := false;
        repeat
           seek(f,ii);
           read(f,datos);
           if datos.codigo = c then
           enco := true
         else
           ii := ii + 1;
        until (enco = true) or (ii > filesize(f) - 1);
        if (enco = false) and (ii > filesize(f) - 1) then
        rastreacodigo := false
      else
        rastreacodigo := true;
        end;
    end;
 
   procedure entrada_liblos;
   begin
      clrscr;
      writeln('**** Entrada De Libros A biblioteca ****');
      writeln;
      write('  Titulo        : ');
      readln(datos.ellibro.titulo);
      write('  Autor         : ');
      readln(datos.ellibro.autor);
      write('  Editorial     : ');
      readln(datos.ellibro.editorial);
      write('  Fecha Edicion : ');
      readln(datos.ellibro.fechaedit);
      datos.ellibro.estado := true;
      write('  Fecha Entrada : ');
      readln(datos.fech_acqui);
      write('  Num. Codigo   : ');
      readln(datos.codigo);
      if rastreacodigo(datos.codigo) = true then
      begin
         clrscr;
         writeln('El Codigo Insertado Ya Existe Pulse [Enter]');
         readln;
         exit;
      end
    else
      begin
      assign(f,'registro.dat');
   {$I-} reset(f); {$I+}
   if ioresult <> 0 then
   begin
       rewrite(f);
       seek(f,0);
       write(f,datos);
       close(f);
    end
  else
      begin
         seek(f,filesize(f));
         write(f,datos);
         close(f);
      end;
   end;
 end;
 
  procedure activaprestamo;
  var
     i, codi : longint;
     sal : boolean;
     tec : char;
  begin
      clrscr;
      writeln('***** Entrada Prestamo Libro *****');
      writeln;
      write('   Entre Num. Codigo : ');
      readln(codi);
      i := 0;
      sal := false;
      assign(f,'registro.dat');
   {$I-} reset(f); {$I+}
   if ioresult <> 0 then
   begin
       writeln('Error De Archivo No Encontrado Pulse [Enter]');
       readln;
       exit;
     end
   else
     begin
    repeat
        seek(f,i);
        read(f,datos);
        if datos.codigo = codi then
        sal := true
      else
         i := i + 1;
    until (sal = true) or (i > filesize(f) - 1);
    if sal = true then
    begin
        clrscr;
        if datos.ellibro.estado = true then
        begin
           writeln('**** Datos Del Libro Solicitado ****');
           writeln;
           writeln('  Titulo        : ',datos.ellibro.titulo);
           writeln('  Autor         : ',datos.ellibro.autor);
           writeln('  Editorial     : ',datos.ellibro.editorial);
           writeln('  Fecha Edicion : ',datos.ellibro.fechaedit);
           writeln;
           writeln('<<<< Es Correcta La Entrega [S/N] >>>>');
           repeat
              tec := readkey;
           until tec in['s','S','n','N'];
           if tec in['s','S'] then
           begin
              datos.ellibro.estado := false;
              seek(f,i);
              write(f,datos);
           end;
        end
      else
         begin
            writeln('El Libro Solicitado Se Encuentra Prestado');
            writeln('Pulse [Enter]');
         end;
      end;
        close(f);
   end;
 end;
 
  procedure listadolibros;
  var
    c, i : longint;
   begin
   clrscr;
   assign(f,'registro.dat');
   {$I-} reset(f); {$I+}
   if ioresult <> 0 then
   begin
      writeln('Error De Archivo No Se Encontro Pulse [Enter]');
      readln;
      exit;
   end
 else
    begin
       c := 0;
       for i := 0 to filesize(f) - 1 do
       begin
          seek(f,i);
          read(f,datos);
          writeln('  Titulo           : ',datos.ellibro.titulo);
          writeln('  Autor            : ',datos.ellibro.autor);
          writeln('  Editorial        : ',datos.ellibro.editorial);
          writeln('  Fecha Edicion    : ',datos.ellibro.fechaedit);
          if datos.ellibro.estado = true then
          writeln('  Situacion Aptual : En Biblioteca')
        else
          writeln('  Situacion Aptual : Prestado');
          c := c + 5;
          if c > 25 then
          begin
             writeln;
             writeln('**** Pulse Una Tecla ****');
             readkey;
             clrscr;
             c := 0;
          end;
       end;
    end;
       writeln;
       writeln('**** Pulse [Enter] ****');
       readln;
       close(f);
  end;
 
   procedure menu;
   var
      ter : char;
      sal : boolean;
   begin
      sal := false;
    repeat
        clrscr;
        writeln('***** Menu Jeneral *****');
        writeln;
        writeln('  [1] = Entrada De Libros');
        writeln('  [2] = Prestamo De Libros');
        writeln('  [3] = Listar Libros');
        writeln('  [4] = Salir');
        writeln;
        writeln('<<< Elija Opcion >>>');
        repeat
           ter := readkey;
        until ter in['1','2','3','4'];
        clrscr;
    case ter of
 '1' : entrada_liblos;
 '2' : activaprestamo;
 '3' : listadolibros;
 '4' : sal := true;
    end;
    until sal = true;
  end;
 
 
 begin
    menu;
 end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

ramon necesito ayuda con un jercicio con lazarus/pascal

Publicado por jorge giron (2 intervenciones) el 23/02/2013 01:39:50
gracias ramon fue de gran ayuda
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar