- 论坛徽章:
- 0
|
Question 1
Write a class My Triangle that implements the mutiple interfaces Translatable, and Scalable provided below. The class encapsulates 3 points from the mutuable class Mpoint. Do not provide any of the inquiry or mutator methods. Note that a triangle is translatable by a given distance dx and dy by adding them to the x and y coordinates of all of its 3 points respectively. Also, a triangle is scalable by a factor s by multiplying the x and y coordinates of all of its 3 points by s.
Public interface Translatable
{public void translate (double dx, double by);}
public interface Scalable
{public void scale(double s);}
Question 2
Write a complete program (without the import statements) that takes from the command line the names of an input and an output text files. The program reads from the input text file a line at a time (until the end of the file), and writes only the lines starting with the letter ‘T’. Use the char At () method to extract the first character of the line that was read. Use the Buffered Reader and Print Writer classes. They can be opened as follows:
BufferedReader inFile = new Buffered Rader (new File Reader (input File Name));
PrintWriter outFile=new PrintWriter (new Buffered Writer (new File Writer (outputFile Name)));
谢谢大大 |
|