file operator code 1 // The FileOperator class that includes methods for file input and output 2 // Your name 3 import java.io.*; 4 public class FileOperator 5 { 6 // instance variables 7 private File m_file; 8 9 // constructor 10 // Do not make any changes to this method! 11 public FileOperator() 12 { 13 String fileName = "employeeData.txt"; 14 m_file = new File(fileName); 15 } 16 17 // This method writes an array of Employees into a physical file. 18 // Each line is in this format: "S-Optimus Prime-Computer Science-$1200" 19 // "S" represents StudentWorker ("F" represents Faculty) 20 public void writeFile(Employee[] employees) 21 { 22 // TODO: implement this method 23 } 24 }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
file operator code 1 // The FileOperator class that includes methods for file input and output 2 // Your name 3 import java.io.*; 4 public class FileOperator 5 { 6 // instance variables 7 private File m_file; 8 9 // constructor 10 // Do not make any changes to this method! 11 public FileOperator() 12 { 13 String fileName = "employeeData.txt"; 14 m_file = new File(fileName); 15 } 16 17 // This method writes an array of Employees into a physical file. 18 // Each line is in this format: "S-Optimus Prime-Computer Science-$1200" 19 // "S" represents StudentWorker ("F" represents Faculty) 20 public void writeFile(Employee[] employees) 21 { 22 // TODO: implement this method 23 } 24 }
For the FileOperator class, the class skeleton is already provided to you. The only method
you should modify and implement is writeFile. This method takes an array of employees,
and each element can be a Faculty object or a StudentWorker object. Your task is to
identify the type of the object using the instanceof keyword and write a line representing this
object to the file using reference m_file. If the current object is a Faculty, then add a prefix
"F-" to the string returned by getPaycheck and write this line to the file. Otherwise, if the
current object is a StudentWorker, the prefix should be "S-". For example:
S-Optimus Prime-Computer Science-$1200
F-Pooh-Mathematics-$50000
Transcribed Image Text:For the FileOperator class, the class skeleton is already provided to you. The only method you should modify and implement is writeFile. This method takes an array of employees, and each element can be a Faculty object or a StudentWorker object. Your task is to identify the type of the object using the instanceof keyword and write a line representing this object to the file using reference m_file. If the current object is a Faculty, then add a prefix "F-" to the string returned by getPaycheck and write this line to the file. Otherwise, if the current object is a StudentWorker, the prefix should be "S-". For example: S-Optimus Prime-Computer Science-$1200 F-Pooh-Mathematics-$50000
Expert Solution
Theory

FileWriter class in Java is used to write character-oriented data to a file.

write() method is used to write the string into FileWriter.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY