Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer the following questions using the Position class: public class Position { private int x; private int y; public int getX() { return x; }

Answer the following questions using the Position class:

public class Position

{

private int x;

private int y;

public int getX() { return x; }

public void setX(int x) { this.x = x; }

public int getY() { return y; }

public void setY(int y) { this.y = y; }

}

a). Write a statement that opens file in.txt for input. Use Scanner variable inFile.

b). Write a statement that opens file out.txt for output. Use Formatter variable outFile.

c). Write the statements needed to read a record from the in.txt (opened in question 11). Use the data to create an object of class Position. Each record contains 2 integers one for x and one for y

d). Write the statements needed to write a record to out.txt (opened in question 12). Use the data stored in a Position object named p.

e). Write a statement that opens file in.txt for input. Use ObjectInputStream variable inFile2 to wrap an InputStream object.

f). Write a statement that opens file out.txt for output. Use ObjectOutputStream variable outFile2 to wrap an OutputStream object.

g). Write the statements needed to read a record from the in.txt (opened in question 15). Use the data to create an object of class Position.

h). Write the statements needed to write a record to out.txt (opened in question 16). Use the data stored in a Position object named p.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

=+2. Why is due process important?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago