Pascal/Turbo Pascal - parking pascal

 
Vista:

parking pascal

Publicado por perdido (2 intervenciones) el 13/06/2014 12:44:07
Buenas,
Por falta de tiempo por trabajo me está siendo imposible hacer una practica para la ultima asignatura de la carrera... A ver si alguien me puede más que exarme un cable, tirarme toda la cuerda jejej

Se trata de la gestión de un parking para 50 vehículos máximo. De cada auto se guarda:
Matricula (4 números y 3 caracteres)
Marca
Modelo
Año Matriculación
Dni conductor (8numeros y un carácter alfabetico)
Caracterdel vehiculo (indica si está permitido el acceso o no al parking)

La info se introduce por teclado cuando el vehiculo quiere entrar al parking y se guarda en un fichero binario (Fdiario.dat)
Aparte, habrá otro fichero (historia.dat) que recogerá los datos de todos los vehículos que han entrado alguna vez al parking

Sera preciso para entrar al garaje que el aforo (50 plazas) no esté cubierto y que este permitido el acceso para ese vehiculo. Por ello cuando se da de alta y una vez comprobado que hay plazas en el garaje, habrá que verificar por medio de la matricula del automóvil en el fichero historia.dat si se le permite el acceso. Si no tiene permiso, de devuelve mensaje por pantalla informando. Si no está almacenado en Historia.dat bien por que no haya entrado nunca o por que si tenga permiso, se incluirá en Fdiario.dat
Diariamente Fdiario.dat se volvara en historia.dat, es decir tendremos la opción de que los vehículos almacenados en fdiario.dat que no estén en historia.dat se añadan al final de este segundo fichero. Si se han modificado algo o se le ha dado de baja en el sistema, se modificaran los campos pertienentes sin duplicar el regsitro.

Se gestionará por un menú:
1: Alta de vehiculo (añadir datos de un nuevo vechiulo. Es preciso comprobar que la matricula del vehiculo no este dada de alta previamente. No hay un num máximo de vehículos autorizados
2. Baja del vehiculo ( Dar de baja solicitando para ello la matricula del vehiculo y en caso de existir se modifica el dato pertinente
3. Listado vehículos autorizados: Ordenados por matricula, se creara un fichero de texto llamado listado.txt. Cada vez que se solicite se sobreescribira
4. Listado vehículos aparcados: Muestra un listado con los datos de los vehículos que están dentro del parking ordenados por dni
5. Acceso vehiculo. Comprueba por el numero de matricula si esta autorizado para acceder y si hay espacio en el parking. Solo se negara si no esta autorizado y/o sino hay espacio en el garaje
6. Salida del vehiculo. Se solicita la matricula. Se debe comprobar que el vehiculo este tanto en la lista de vehículos autorizados a entrar como en el registro de vehículos que están dentro del parking. Una vez abandone el parking, debe eliminarse de fdiario.dat y de historia.dat
7. Actualizar datos. Aquí permite hacer el volcado del fichero binario fdiario.dat en historia.dat


Gracias anticipadas....
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
sin imagen de perfil

parking pascal

Publicado por Lolazo (1 intervención) el 15/06/2014 21:22:30
Ha habido suerte figura?
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

parking pascal

Publicado por ramon (2158 intervenciones) el 17/06/2014 00:10:55
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
{Espero esto te encamine a realizar el trabajo suerte}
 
 program parking;
 uses
   crt;
   const
      diario = 'Fdiario.dat';
      historico = 'historia.dat';
      max = 50;
 
   type
      string7 = string[7];
      vehiculo = record
               vaja : boolean;
          matricula : string7;
              marca : string[80];
             modelo : string[50];
  ayo_matriculacion : string[4];
      dni_conductor : string[9];
   caracter_vehicul : boolean;
          end;
 
 
   var
     fichavehicu : array[1..max] of vehiculo;
     cont : integer;
     f : file of vehiculo;
     tec : char;
 
 
 
     procedure actualizaformato(var fom : string7);
     var
       sd : integer;
     begin
        for sd := 1 to length(fom) do
        begin
        fom[sd] := upcase(fom[sd]);
        end;
     end;
 
 
 
     procedure guarda_vehiculo(v : vehiculo);
     begin
        assign(f,diario);
     {$I-} reset(f); {$I+}
        if ioresult <> 0 then
        begin
           rewrite(f);
           seek(f,0);
           write(f,v);
           close(f);
        end
     else
         begin
            seek(f,filesize(f));
            write(f,v);
            close(f);
         end;
     end;
 
     function puede_quedarse(mt : string7) : boolean;
     var
       tp : file of vehiculo;
       dlp : vehiculo;
       jk : longint;
     begin
        actualizaformato(mt);
        puede_quedarse := true;
        assign(tp,historico);
     {$I-} reset(tp); {$I+}
        if ioresult <> 0 then
        begin
        end
     else
         begin
            for jk := 0 to filesize(tp) - 1 do
            begin
               seek(tp,jk);
               read(tp,dlp);
              if dlp.vaja = false then
              begin
               if dlp.matricula = mt then
               begin
                  if dlp.caracter_vehicul = true then
                  break
                else
                   begin
                      writeln;
                      puede_quedarse := false;
                      writeln('  Acceso denegado Pulse Una Tecla');
                      readkey;
                   end;
               end;
             end;
           end;
            close(tp);
         end;
     end;
 
     procedure entrada_vehiculos(h : integer);
     var
        es : boolean;
        pp : longint;
     begin
        clrscr;
        if cont <= max then
        begin
        writeln('    ****** Entrada De Vehiculos ******');
        writeln('    //////////////////////////////////');
        with fichavehicu[h] do
        begin
        vaja := false;
        writeln;
        write('   Entre Matricula        : ');
        readln(matricula);
        actualizaformato(matricula);
        write('   Entre Marca            : ');
        readln(marca);
        write('   Entre Modelo           : ');
        readln(modelo);
        write('   A¤o Matricula.         : ');
        readln(ayo_matriculacion);
        write('   DNI Conductor          : ');
        readln(dni_conductor);
        if (cont <= max) and (puede_quedarse(matricula) = true) then
        caracter_vehicul := true
     else
        caracter_vehicul := false;
       end;
     end;
       if fichavehicu[h].caracter_vehicul = true then
       guarda_vehiculo(fichavehicu[h])
     else
       begin
       writeln('   Aparcamiento Denegado Pulse Una Tecla');
       readkey;
      end;
    end;
 
  procedure archivo_istorico;
  var
     ft : file of vehiculo;
     rr, t, d : longint;
     tepo, dar : vehiculo;
     esi : boolean;
  begin
     assign(f,diario);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('  Error Falta Archivo ',diario,' Pulse Una Tecla');
       readkey;
    end
 else
    begin
     assign(ft,historico);
  {$I-} reset(ft); {$I+}
     if ioresult <> 0 then
     begin
        rewrite(ft);
        for d := 0 to filesize(f) - 1 do
        begin
           seek(f,d);
           read(f,dar);
           seek(ft,d);
           write(ft,dar);
        end;
          close(f);
          close(ft);
      end
  else
     begin
        t := filesize(ft);
        for d := 0 to filesize(f) - 1 do
        begin
           seek(f,d);
           read(f,dar);
         for rr := 0 to filesize(ft) - 1 do
         begin
            seek(ft,rr);
            read(ft,tepo);
            esi := false;
            if (tepo.dni_conductor = dar.dni_conductor) and
               (tepo.matricula = dar.matricula) then
             begin
                break;
                esi := true;
             end;
         end;
           if esi = false then
           begin
           seek(ft,t + d);
           write(ft,dar);
           end;
        end;
          close(f);
          close(ft);
      end;
    end;
  end;
 
  procedure presenta_diario;
  var
    ss : longint;
    dag : vehiculo;
    y : integer;
  begin
      assign(f,diario);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('  Error Falta Archivo ',diario,' Pulse Una Tecla');
       readkey;
    end
 else
    begin
  gotoxy(2,1);write('Matricula   Marca     Modelo     A¤o    Dni    Estado');
       y := 3;
       for ss := 0 to filesize(f) - 1 do
       begin
          seek(f,ss);
          read(f,dag);
          if dag.vaja = false then
          begin
          with dag do
          begin
              gotoxy(2,y);write(matricula);
              gotoxy(14,y);write(marca);
              gotoxy(24,y);write(modelo);
              gotoxy(34,y);write(ayo_matriculacion);
              gotoxy(41,y);write(dni_conductor);
              gotoxy(50,y);write(caracter_vehicul);
              y := y + 1;
              if y > 23 then
              begin
                 gotoxy(12,24);write('Pulse Una Tecla');
                 readkey;
                 y := 3;
                 clrscr;
  gotoxy(2,1);write('Matricula   Marca     Modelo     A¤o    Dni    Estado');
              end;
          end;
         end;
       end;
       close(f);
     end;
  end;
 
  procedure vehiculos_autorizados;
  var
    b : longint;
    veh : vehiculo;
    ft : file of vehiculo;
    y : integer;
  begin
     clrscr;
     assign(ft,historico);
  {$I-} reset(ft); {$I+}
     if ioresult <> 0 then
     begin
        writeln('  Error Falta Archivo ',historico,' Pulse Una Tecla');
        readkey;
     end
  else
     begin
        clrscr;
  gotoxy(2,1);write('Matricula   Marca     Modelo     A¤o    Dni    Estado');
       y := 3;
       for b := 0 to filesize(ft) - 1 do
       begin
          seek(ft,b);
          read(ft,veh);
          if veh.vaja = false then
          begin
          with veh do
          begin
              gotoxy(2,y);write(matricula);
              gotoxy(14,y);write(marca);
              gotoxy(24,y);write(modelo);
              gotoxy(34,y);write(ayo_matriculacion);
              gotoxy(41,y);write(dni_conductor);
              gotoxy(50,y);write(caracter_vehicul);
              y := y + 1;
              if y > 23 then
              begin
                 gotoxy(12,24);write('Pulse Una Tecla');
                 readkey;
                 y := 3;
                 clrscr;
  gotoxy(2,1);write('Matricula   Marca     Modelo     A¤o    Dni    Estado');
              end;
           end;
         end;
       end;
         readkey;
         close(ft);
     end;
  end;
 
 
  procedure menu;
  var
    teca : char;
    sal : boolean;
  begin
     sal := false;
   repeat
      clrscr;
      writeln('      **** Menu General **** ');
      writeln;
      writeln('    1 : Alta de vehiculo');
      writeln('    2 : Baja del vehiculo');
      writeln('    3 : Listado vehiculos autorizados');
      writeln('    4 : Listado vehiculos aparcados');
      writeln('    5 : Acceso vehiculo');
      writeln('    6 : Salida del vehiculo');
      writeln('    7 : Actualizar datos');
      writeln('    8 : Salir');
      writeln;
      writeln('   Elija Opcion ');
     repeat
        teca := readkey;
     until teca in['1','2','3','4','5','6','7','8'];
     clrscr;
     case teca of
  '1' : begin
       entrada_vehiculos(cont);
       archivo_istorico;
        cont := cont + 1;
       if cont > max then
        cont := max;
       end;
  '2' :;
  '3' : begin
          vehiculos_autorizados;
          readkey;
        end;
  '4' : begin
        presenta_diario;
        readkey;
       end;
  '5' :;
  '6' :;
  '7' :;
  '8' : sal := true;
    end;
   until sal = true;
  end;
 
   begin
      cont := 1;
      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
0
Comentar