1
To do this, you must create classes:
Item (available (Boolean), loan date, return date, name and
code). Use the Calendar class to manage dates.
Book (author and loan period - 14 days and should be static attribute)
CD (number of tracks and loan period - 5 days)
DVD (duration and loan period - 3 days)
Client (name, CPF and telephone)
Loan (customer and item)
Vector (Interface - inserts, removes and searches)
Vetor de Cliente
Vetor de Locação
Item vector
I’ve come this far. Someone can help me?
public class Emprestimo {
static StringBuffer memoria = new StringBuffer();
static String arquivo = "Emprestimo.txt";
static void iniciarArquivo() {
String linha;
try {
BufferedReader arqEntrada;
arqEntrada = new BufferedReader(new FileReader("Emprestimo.txt"));
memoria.delete(0, memoria.length());
while ((linha = arqEntrada.readLine()) != null) {
memoria.append(linha + "\n");
}
arqEntrada.close();
} catch (FileNotFoundException erro1) {
JOptionPane.showMessageDialog(null, "Arquivo não encontrado.");
} catch (Exception erro2) {
JOptionPane.showMessageDialog(null, "Erro de leitura!");
}
}
public static void gravarDados() {
try {
String arquivo = "Emprestimo.txt";
BufferedWriter saida;
saida = new BufferedWriter(new FileWriter(arquivo, false));
saida.write(memoria.toString());
saida.flush();
saida.close();
} catch (Exception erro3) {
JOptionPane.showMessageDialog(null, "Erro de gravação");
}
}
public static void Locar (){
}
public static void Devolver (){
}
}
You must create an Item class, a Book class, a CD class, a DVD class and a Loan class. The loan class must have the client and item fields/attributes. That is, what you did there is all wrong, because these are not the loan fields/attributes. Also, nowhere in that statement does it say that it is to save whatever it is in files.
– Victor Stafusa
Welcome to [en.so]. Describing the general problem you will only get a general answer. Example: "How to build a house?" , "Use blocks and cement, build solid walls". Instead ask something specific and responsive in a useful way: "How to lift a wall using this type of block with such a slope and such height safely?" , answer: "Position the blocks in such format, run this block placement algorithm, do not use this tool because there is such a risk, here is a working example of a wall ready for you to see". Very broad questions don’t help.
– Jéf Bueno