Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- import se.lth.cs.ptdc.window.SimpleWindow;
- public class ShapeTest {
- public static void main(String[] args) throws FileNotFoundException {
- SimpleWindow w = new SimpleWindow(600, 600, "ShapeTest");
- ShapeList shapes = new ShapeList();
- Scanner scan = new Scanner(new File("shapedata.txt"));
- int x,y,z;
- while(scan.hasNext()) {
- String s = scan.next();
- if (s == "S"){
- x = scan.nextInt();
- y = scan.nextInt();
- z = scan.nextInt();
- shapes.insert(new Square(x,y,z));
- } else if (s == "C") {
- x = scan.nextInt();
- y = scan.nextInt();
- z = scan.nextInt();
- shapes.insert(new Circle(x,y,z));
- } else if (s == "T") {
- x = scan.nextInt();
- y = scan.nextInt();
- z = scan.nextInt();
- shapes.insert(new Square(x,y,z));
- }
- }
- shapes.draw(w);
- // shapes.insert(new Square(100, 300, 100));
- // shapes.insert(new Triangle(400, 200, 100));
- // shapes.insert(new Circle(400, 400, 50));
- // shapes.insert(new Square(450, 450, 50));
- // shapes.insert(new Square(200, 200, 35));
- // shapes.draw(w);
- CommandDispatcher cd = new CommandDispatcher(w,shapes);
- cd.mainLoop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement