subject

The shell project will compile and execute, and even read a stream file and populate the list with data from a string file.

Steps

You are then asked to complete the following TODO action items:

Review the FileStream Class and:

in the readlist method add the statements to add a string to the array list
in the writeData method add the statement to write the string to the file
Review the PizzaFileIO class and:

In the writeData method add code to add the missing order fields to the record
In the readData method add code to add the missing fields to the order object
Review the OrderList class

In the remove method add statements to remove the order from the list
In the save method add the statement to write the array list to the file.
Graphical User Interface

Update the given graphical user interface to:

Save the list in the Order list to a file using both types of file I/O (streams and objects).
Retrieve the list from the file and display the list
Add a menu items Save Orders and Retrieve Orders
Update retrieveOrders method to retrieve the list from the orderList object.
in OrderList. java;

public void remove(PizzaOrder aOrder) {

if (aOrder != null) {

//TODO: remove the order object from the arraylist

}

}

public int save() throws IOException {

int count = 0;

//TODO: write the array list to file

return count;

}

public int retrieve(DefaultListModel listModel) throws IllegalArgumentException, IOException {

int count = 0;

orderList = streamFile. readData();

if (!orderList. isEmpty()) {

listModel. clear();

count = orderList. size();

for(PizzaOrder order : orderList) {

listModel. addElement(order);

}

}

public void remove(PizzaOrder aOrder) {

if (aOrder != null) {

//TODO: remove the order object from the arraylist

}

}

public int save() throws IOException {

int count = 0;

//TODO: write the array list to file

return count;

}

//Pizza_Main. java

private void retrieveOrders() throws IllegalArgumentException, IOException {

int count = 0;

//TODO: add statement to retrieved the order list (remember to pass in the list model)

String message = count + " pizza orders retreived from file: " + orderList. getFileName();

JOptionPane. showMessageDialog(null, message, "Orders Retrieved", JOptionPane. PLAIN_MESSAGE);

}

//FileStream. java

public static Boolean writeData(String data, String fileName) throws IOException

{

Boolean success;

try

{

FileWriter dataFile = new FileWriter(fileName, false);

try (PrintWriter output = new PrintWriter(dataFile)) {

//TODO: provide the statement to write the entire data string to the file

}

success = true;

}

catch (IOException ioe)

{

JOptionPane. showMessageDialog(null, ioe. getMessage(), "File Write Error", JOptionPane. ERROR);

success = false;

}

return success;

}

public static ArrayList readList(String fileName) throws FileNotFoundException, IllegalArgumentException, IOException

{

ArrayList dataList = new ArrayList<>();

String str;

try {

String file = checkFile(fileName);

try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {

while ((str = br. readLine()) != null)

{

//TODO: write the statement to add the string to the arrayList

}

}

}

catch (IOException ioe)

{

JOptionPane. showMessageDialog(null, ioe. getMessage(), "File Read Error", JOptionPane. ERROR);

dataList = null;

}

return dataList;

}

//FileStream. java

public static Boolean writeData(String data, String fileName) throws IOException

{

Boolean success;

try

{

FileWriter dataFile = new FileWriter(fileName, false);

try (PrintWriter output = new PrintWriter(dataFile)) {

//TODO: provide the statement to write the entire data string to the file

}

success = true;

}

catch (IOException ioe)

{

JOptionPane. showMessageDialog(null, ioe. getMessage(), "File Write Error", JOptionPane. ERROR);

success = false;

}

return success;

}

try {

String file = checkFile(fileName);

try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {

while ((str = br. readLine()) != null)

{

//TODO: write the statement to add the string to the arrayList

}

//PizzaFileO. java

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

//2. add the statement to add the ham value to the record

//3. add the statements to add the total value to the record

aOrder. setCheese(Boolean. valueOf(row. nextToken()));

//TODO: add statements to:

//1. add the sausage value to the order object

//2. add the ham order to the object

//3. add the total value to the order (keeping in mind you have to "parse" the value into a double

//4. add the order to the array list

}

}

}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:40, lazerlemon500
Write a modular program (no classes yet, just from what you learned last year), that allows two players to play a game of tic-tac-toe. use a two-dimensional char array with 3 rows and 3 columns as the game board. each element of the array should be initialized with an asterisk (*). the program should display the initial board configuration and then start a loop that does the following: allow player 1 to select a location on the board for an x by entering a row and column number. then redisplay the board with an x replacing the * in the chosen location. if there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an o by entering a row and column number. then redisplay the board with an o replacing the * in the chosen location. the loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. player 1 wins when there are three xs in a row, a column, or a diagonal on the game board. player 2 wins when there are three ox in a row, a column, or a diagonal on the game board. a tie occurs when all of the locations on the board are full, but there is no winner. input validation: only allow legal moves to be entered. the row must be 1, 2, or 3. the column must be 1, 2 3. the (row, column) position entered must currently be empty (i. e., still have an asterisk in it).
Answers: 1
image
Computers and Technology, 24.06.2019 13:10, Briannas5022
Write a program that has a conversation with the user. the program must ask for both strings and numbers as input. the program must ask for at least 4 different inputs from the user. the program must reuse at least 3 inputs in what it displays on the screen. the program must perform some form of arithmetic operation on the numbers the user inputs. turn in your .py file as well as a screenshot of your program's output. include comments in your code to explain how it works an example program run might look like (have fun with this and be creative): ‘what is your name? ’ “josh” ‘, josh. what is your favorite color? ’ “green” ‘mine too. do you also like ice cream? ’ “no” ‘josh, how old are you? ’ “40” ‘ and how many siblings do you have? ’’ “3” ‘that means you are one of 4 kid(s). is green the favorite color of anyone else in your house? ’
Answers: 3
image
Computers and Technology, 24.06.2019 16:50, Ameilasmickle15
How many types of string types does python support?
Answers: 1
image
Computers and Technology, 24.06.2019 21:30, croxy0514
Jenny wants to create an animated short video to add to her website. which software will she use to create this animated video?
Answers: 1
You know the right answer?
The shell project will compile and execute, and even read a stream file and populate the list with d...

Questions in other subjects: