0
Develop Student Record and Information System using Java language. It must be used to store, administer and manage all aspects
Java
4 Respostas
+ 1
Off the top of my head:
1. create a folder in project named âStudentsâ
2. Create a class for adding students and adding records, addStudent() would create a folder in the âStudentsâ folder named the student name or ID based on the input. For example âproject/Students/001 Joe Smithâ and in that folder it would create a .txt file named âinformation.txtâ as well as a folder named ârecordsâ so in every student folder there would be a ârecordsâ folder and an âinformation.txtâ - So when you run the addStudent method of this class it would prompt input to add âStudent First Name: Joe - Student Last Name: Smith - ID: 001 and any other information necessary, then that would create the student folder based on name/id as well as write that information to the information.txt. When you run the addRecord() method, it would create a .txt file within the records folder of this student with the name of your choice based on input IE: âtest scores 6/5/19.txtâ and within that file, any information youâve specified.
3. Create a class that can retrieve a students folder based on input (IE: name and/or ID), and the information within that folder IE: the information.txt file and the contents of the records folder and then stores this information to individual containers (Such as ArrayLists)
4. Create a class for editing Students with methods such as editStudent(), editRecord(). This will utilize the class in step 3 for retrieving a students folder, editStudent would be responsible for editing the information.txt, if the name or id is changed, it will change the name of the students folder as well. Once editing is complete, it will overwrite whichever folders/files were edited
Iâm typing this off the top of my head so Iâm not really sure how this sounds or how proficient this would be haha, there are always better ways to do something, but this is one idea to get you started.
If you need any assistance on writing/reading files you can check out my code:
https://code.sololearn.com/crneHXo01yiI/?ref=app
+ 5
Have you started anything yet?
+ 1
public class FileUtilities
{
///// CREATE A NEW FILE /////
static void createFile(String directory, String filename) {
File fileDirectory = new File(directory + "\\" + filename);
if(fileDirectory.exists()) {
System.out.printf("File: '%s' already exists.\n", filename);
}
else {
try {
fileDirectory.createNewFile();
} catch (IOException e) {
System.out.printf("Failed to create new file: '%s'\n", filename);
}
}
} //END createFile()
///// WRITE TO FILE /////
static void writeToFile(String directory, String[] content) {
try(FileWriter fw = new FileWriter(directory, true)){
BufferedWriter bw = new BufferedWriter(fw);
for(String line : content) {
if(line != null) {
bw.write(line);
bw.newLine();
}
} // end loop
bw.flush();
bw.close();
} catch (IOException e) {
System.out.println("Failed to write to file: '" +directory+ "'");
}
} //END writeToFile()
///// GET FILE CONTENTS AS STRING /////
static String getFileContents(String directory) {
try {
byte[] encoded = Files.readAllBytes(Paths.get(directory));
return new String(encoded, Charset.defaultCharset());
} catch (IOException e) {
return "Failed to read file: '" +directory+ "'";
}
} //END getFileContents()
public static void main(String[] args) {
final String DESKTOP_PATH = System.getProperty("user.home") + "\\Desktop";
//absolute path to users desktop
final String DATA_FILE = "data.txt";
// name of file to create/reference
final String DATA_PATH = DESKTOP_PATH + "\\" + DATA_FILE;
//absolute path to the file
String[] fileContents = {"name: myName", "age: myAge", "location: myLocation"};
//example content written to file
FileUtilities.createFile(DESKTOP_PATH, DATA_FILE);
FileUtilities.writeToFile(DATA_PATH, fileContents);
System.out.println(FileUtilities.getFileContents(DATA_PATH));
} //END main
} // END class
0
Yes, it's a bit unreliable though