joshSawYou / CIS255_Vehicle

0 stars 0 forks source link

Class - File Handler #11

Closed jwood36 closed 1 year ago

jwood36 commented 1 year ago
  • Create a File Handler to output the Storage Class to a File

    File should be a simple CSV, with a Header Row Each row will be terminated with a CRLF or New-Line character File Extension: csv Delimiter Character: | (pipe symbol)

joshSawYou commented 1 year ago

I've had a SaveToFile() method in my main method that calls the saveToFile() method in my vehicleStorage class. In the vehicleStorage class, there is a saveToFile() method as well. In this, saveToFile method, it prompts the user for the file name, if they have not provided the extension: ".csv" then the program adds it for them. It adds a header row to the file. The format for the data to be saved to the file is " String row = make + "|" + vehicleType + "|" + model + "|" + year + "|" + engineType + "|" + doorCount + "|" + color + "\n";" The "\n" at the end of each row ensure that each row will be terminated with a New Line Character. The pipelines provide the delimeter character.