Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modificacion #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 59 additions & 8 deletions src/binarios/cinemark/Cinemark.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Calendar;
import java.util.Date;

/**
Expand Down Expand Up @@ -218,8 +219,7 @@ public boolean venderTicket(int sala, int asiento)throws IOException{
}
return false;
}

/*
/*
TRABAJO EN GRUPO 3:
-------------------------------------
1- (10%)En vender ticket, validar que la sala tenga una pelicula asignada, que
Expand All @@ -238,8 +238,12 @@ public boolean venderTicket(int sala, int asiento)throws IOException{
* Si la sala NO existe, se imprime dicha información.
* @param sala Numero de la sala
* @param beginning Fecha de inicio del reporte
* @throws java.io.IOException
*/
public void ticketsSoldInSala(int sala, Date beginning){
public void ticketsSoldInSala(int sala, Date beginning)throws IOException{
RandomAccessFile rs = getSalaFile(sala);
System.out.println("Codigo Pelicula: "+rs.readInt());
System.out.println("Nombre Pelicula: "+rs.readUTF());

}

Expand Down Expand Up @@ -267,9 +271,44 @@ public void cartelera(String txtfile){
* @param cp Codigo de la pelicula
* @return Retornar true si se pudo inhabilitar o no.
*/
public boolean disableMovie(int cp){
public boolean existPelicula(int cp)throws IOException{
rp.seek(0);
while(rp.getFilePointer() < rp.length()){
if(cp == rp.readInt()){
return true;
}
rp.readUTF();
rp.readLong();
rp.readUTF();
rp.readUTF();
rp.readDouble();
rp.readBoolean();

}
return false;
}

}

public boolean disableMovie(int cp)throws IOException{
if(existPelicula(cp)){
rp.seek(0);
while(rp.getFilePointer() < rp.length()){
int c = rp.readInt();
rp.readUTF();
rp.readLong();
rp.readUTF();
rp.readUTF();
rp.readDouble();
if(c == cp){
rp.writeBoolean(false);
return true;
}else{
rp.readBoolean();
}
}
}
return false;
}

/**
* 5- (15%)Funcion que vuelve a escribir false TODOS los asientos de una Sala
Expand All @@ -278,8 +317,21 @@ public boolean disableMovie(int cp){
* limpiar la sala.
* @param sala Numero de la sala
*/
public void cleanSala(int sala){

public void cleanSala(int sala)throws IOException{
Calendar hour = Calendar.getInstance();
if(23 == hour.get(Calendar.HOUR_OF_DAY)){
if(existsSala(sala)){
RandomAccessFile rs = getSalaFile(sala);
rs.readInt();
rs.readUTF();
rs.readDouble();
rs.readUTF();
int c = rs.readInt();
for(int x=1; x <= c; x++){
rs.writeBoolean(false);
}
}
}
}

/**
Expand All @@ -296,6 +348,5 @@ public void taquilleras(int minimo){
*/




}