You will use the split method for reading the lines in the file. If the customer
ID: 3748885 • Letter: Y
Question
You will use the split method for reading the lines in the file.
If the customer already exists on the customer list, just add the rental to their rental list.
You will turn in Address.java, Customer.java, MavRental.java, Invoice.java, Rental.java,
FurnitureRental.java, ElectronicRental.java, MavGUI.java, WriteCustomers.java, ReadCustomers.java,
MavGUITest.java. Zip them into a file named HW1.zip
Adhere to coding standards Due September 18 by class time. ustomer -name: String -address: Address Invoice No setRentalusttCardNumber String -rentalList:ArrayListcRental> printinvoice) String addRentaRental R) Rental MavRental No setcustsmerlast.pricePerDay.double -customerList +addCustomer(customer c +customerExists(String name):boolean street:Stri t calculateCha city:String -zip:Stri FurnitureRental ElectronicRental +enum Furniture fTvpe:FurnitureTvpe e Ivpe BED, COUCH, CHAIR +enum Electronic COMPUTE ElectronicTvpeExplanation / Answer
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; // main class public class Main { // for saving word objects private ArrayList words; public static void main(String[] args) throws IOException { Main main = new Main(); main.start();//start } private void start() throws IOException { readFile(); // read file printWords(); // print results } private void readFile()throws IOException{ BufferedReader input = new BufferedReader(new FileReader("tl.txt")); words = new ArrayList(); int lineNum = 1; // we read first line in start // delimeters of line in this example only "space" char [] parse = {' '}; String delims = new String(parse); String line = input.readLine(); // read line while end of file while(line != null){ String [] lineWords = line.split(delims); // split the words and create word object for (int i = 0; i line number i+1--> words index in line words.add(w); // lineWords[i] is word } lineNum++; // pass the next line line = input.readLine(); } } // print out the results private void printWords() { System.out.println("WORD LINE INDEX"); System.out.println(); for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.