I am not sure how to add the object to the array
/in Feeds /by Munene davidYes. I need help finding what to put under the number 4 comment. I am not sure how to add the object to the array
list.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package data;
import java.io.*;
import java.util.ArrayList;
import business.*;
import java.util.StringTokenizer;
public class PizzaFileIO {
public static final String DEFAULT_FILE_NAME = “order.dat”;
public static final String DELIMTER = “,”;
private String fileName;
public PizzaFileIO() {
fileName = DEFAULT_FILE_NAME;
}
public PizzaFileIO(String fileName) {
setFileName(fileName);
}
public final void setFileName(String fileName) {
if (fileName != null && !fileName.trim().isEmpty())
{
this.fileName = DEFAULT_FILE_NAME;
}
else {
this.fileName = fileName;
}
}
public String getFileName() {
return fileName;
}
public int writeData(ArrayList<PizzaOrder> orderList) throws IOException {
StringBuilder recordList = new StringBuilder();
int count = 0;
if(!orderList.isEmpty()) {
for(PizzaOrder aOrder:orderList) {
count++;
recordList.append(aOrder.getFirstName());
recordList.append(DELIMTER);
recordList.append(aOrder.getLastName());
recordList.append(DELIMTER);
recordList.append(aOrder.getPizzaSize());
recordList.append(DELIMTER);
recordList.append(aOrder.getCheese());
recordList.append(DELIMTER);
//TODO, write the code to: (remember to separate the fields by the delimiter)
//1. add the statement to add the sausage value to the record
recordList.append(aOrder.getSausage());
//2. add the statement to add the ham value to the record
recordList.append(aOrder.getHam());
//3. add the statements to add the total value to the record
recordList.append(aOrder.getTotal());
if (count < orderList.size())
recordList.append(“rn”);
}
FileStream.writeData(recordList.toString(), fileName);
}
return count;
}
public ArrayList<PizzaOrder> readData() throws IllegalArgumentException, IOException {
PizzaOrder aOrder;
ArrayList<String> recordList;
ArrayList<PizzaOrder> orderList = new ArrayList<>();
StringTokenizer row;
recordList = FileStream.readList(fileName);
if (!recordList.isEmpty()) {
for(String record:recordList) {
row = new StringTokenizer(record, DELIMTER);
if (row.countTokens() == 7) {
aOrder = new PizzaOrder();
aOrder.setFirstName(row.nextToken());
aOrder.setLastName(row.nextToken());
aOrder.setPizzaSize(row.nextToken());
aOrder.setCheese(Boolean.valueOf(row.nextToken()));
//TODO: add statements to:
//1. add the sausage value to the order object
aOrder.setSausage(Boolean.valueOf(row.nextToken()));
//2. add the ham order to the object
aOrder.setHam(Boolean.valueOf(row.nextToken()));
//3. add the total value to the order (keeping in mind you have to “parse” the value into a double
aOrder.setTotal(Double.parseDouble(row.nextToken()));
//4. add the order to the array list
recordList.add(new PizzaOrder(aOrder));
}
}
}
return orderList;
}
}
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"
I need to an if or else statement and I am not sure how to do that I am doing work in C++ right now
/in Feeds /by Munene davidSuppose you have observed that your system is performing more slowly than usual.
/in Feeds /by Munene davidSuppose you have observed that your system is performing more slowly than usual. It also takes much longer just to
show the login screen. Applications are taking longer to load; switching among tasks is also taking longer and may even cause some applications to crash.
Which system resources are likely to be at the root of the problem?
Can there also be a security issue? If so, then what actions should you consider?
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"
About Us
![]()
Since 2010, we have offered professional writing services to clients all over the world.
Over the years, our writers have gained solid experience in all academic disciplines, giving them a competitive edge to provide only first-rate academic papers.
![]()
QUICK LINKS
Contact Us
For any questions, feedback, or comments, we have an ethical customer support team that is always waiting on the line for your inquiries.
Talk to us
support@academicheroes.com
Call us: +1 (203) -677 0547