Write a class GraphicsInterperter that reads in a file of graphics commands. The class GraphicsInterpreter should have a method interpretCommands that takes a filename as input (a String), reads the graphics commands from the file, and then returns a Picture with the graphics commands executed on it. The method interpretCommands starts out by creating a 640x480 blank picture, then draws on that, and returns it.
There are two kinds of commands:
“line 10 20 300 400” should draw a line from (10, 20) to (300, 400). You can assume that those are single spaces between the co-ordinates.
“circle 100 200 10” draws a circle whose upper-left hand corner is (100, 200) with a diameter for 10.
An input graphics command might look like:
circle 20 20 100
circle 300 20 100
line 210 120 210 320
line 210 320 310 320
line 20 350 400 350
The main method for GraphicsInterpreter might look like this:
```
public s t a t i c void main ( S t r i n g [ ] a r g s )
{
G r a p h i c s I n t e r p r e t e r i n t e r p r e t e r = new G r a p h i c s I n t e r p r e t e r ( ) ;
S t r i n g f i l e N a m e = F i l e C h o o s e r . getMediaPath ( ” g r a p h i c s ?commands . t x t ” ) ; P i c t u r e p = i n t e r p r e t e r . interpretCommands ( f i l e N a m e ) ;
p . show ( ) ;
}
```
This is left to the student.
You might also like to view...
An index is a sequence of folders that leads to a specific file or folder
Indicate whether the statement is true or false
The ____ keys move the active cell left one cell.
A. Ctrl+F5 B. Shift+Tab C. Alt+Enter D. Esc+Enter