⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testshape.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
import java.io.*;
import dslib.base.PairUos;

/** A class to test the shape classes at the end of Chapter 6 */
public class TestShape
{
	public static void main(String args[]) throws Exception
	{
		PrintWriter outfile = new PrintWriter(new FileWriter("OutputTestShape.txt"));

		Circle c = new Circle(5);
		Shape temp = c;
		outfile.print(temp);
		Rectangle r = new Rectangle(5, 9);
		temp = r;
		outfile.print(temp);
		Square s = new Square(9);
		temp = s;
		outfile.print(temp);

		c.goPosition(100, 30);
		Figure first = new Figure("first");
		first.insert(c);
		outfile.print(first);

		Figure second = new Figure("second");
		second.insert(c);
		r.goPosition(130, 60);
		second.insert(r);
		second.shift(50, 50);  
		outfile.print(second);

		second.insert(first);  // second now has two references to c, one directly and one via first
		Figure third = new Figure("third");
		third.insert(second);
		first.shift(100, 100);
		third.insert(first);
		third.shift(-200, -200);  // the circle c is shifted three times
		outfile.print(third);

		RotateFigure rf = new RotateFigure("rotatable figure");
		rf.insert(c);
		rf.insert(r);
		rf.insert(s);
		rf.rotate(45);
		outfile.print(rf);

		outfile.close();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -