急急急!!!java长方形图形重叠!!跪求帮助!!没时间了!拜托大家!

玉石玲珑 2011-04-20 04:49:55
我真的不会做!没时间了!要在4月22号前完成阿! 跪求有能力人士帮忙下!这是其中一道作业!!谢谢大家了!!!!请帮忙解答案,请把答案付上!多谢!
要写3个文件 Point.java, Rectangle.java, TheOrder.java ( TheOrderTest.java)已给

下面红色区好像是最后的答案,看起来是这样!

这是Output from "crude test" for TheOrder
(原始窗)Original order of windows:"<(2,2),6,8>,<(3,5),6,8>,<(5,7),6,8>"

(经过点击点)After clicking point (4,4):"<(3,5),6,8>,<(5,7),6,8>,<(2,2),6,8>"

(在次点击)After AGAIN clicking point (4,4):"<(3,5),6,8>,<(5,7),6,8>,<(2,2),6,8>"

(经过点击点)After clicking point (10,10):"<(3,5),6,8>,<(2,2),6,8>,<(5,7),6,8>"

"<(3,5),6,8>,<(2,2),6,8>,<(5,7),6,8>,<(7,1),20,12>"

"<(3,5),6,8>,<(2,2),6,8>,<(5,7),6,8>,<(7,1),20,12>"




以给程序~ 
public class TheOrderTest {
public static void main( String [ ] args ) {
TheOrder myWindows = new TheOrder();

Point[] testPoints = new Point[ 3 ];
testPoints[0] = new Point( 2, 2 );
testPoints[1] = new Point( 3, 5 );
testPoints[2] = new Point( 5, 7 );

Rectangle[] testRects = new Rectangle[ 3 ];
testRects[ 0 ] = new Rectangle( testPoints[0], 6, 8 );
testRects[ 1 ] = new Rectangle( testPoints[1], 6, 8 );
testRects[ 2 ] = new Rectangle( testPoints[2], 6, 8 );

for( int i = 0; i< testRects.length; i++ ) {
myWindows.addWindow( testRects[i] );
}

System.out.println( "Original order of windows:" );
System.out.println( myWindows );

Point p1 = new Point( 4, 4 );
myWindows.click( p1 );
System.out.println( "After clicking point " + p1 + ":" );
System.out.println( myWindows );

myWindows.click( p1 );
System.out.println( "After AGAIN clicking point " + p1 + ":" );
System.out.println( myWindows );

Point p2 = new Point( 10, 10 );
myWindows.click( p2 );
System.out.println( "After clicking point " + p2 + ":" );
System.out.println( myWindows );

}
}

Java长方形图形重叠,重叠的矩形二维窗口区域,在列表中的矩形命令意味着它们的顺序将显示在屏幕上从0(有时被称为“Z -顺序“)上的底部,大小() -在顶部1。

详情:
写class named TheOrder, 长方形(x,y)长,宽。(x,y)的位置
 class named Rectangle 应该是一个point(点),如下所述。
 The class name Point 要有implement the Point class在个功课中。
您的矩形列表类,TheOrder,将保持一个矩形的ArrayList来实现的可能重叠的矩形二维窗口地区的样板。

您的矩形列表类,TheOrder,应该有一个方法,它作为一个参数一个点,就像对待用户点击它的点在屏幕上,并移动最上面的矩形感人指向​​列表的前面,留下的顺序对其余的名单不变。

要写命名TheOrderTest来测试你的代码的类。这个类只包含主要方法,实例化一个类型TheOrder对象,初始化它,并测试它。尽可能完成这项测试。请记住,我们使用TheOrder代表的z屏幕的显示顺序。
...全文
278 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
gentalguo 2011-04-22
  • 打赏
  • 举报
回复
I have worked for about five years.
My age? Of course, it's not a secret.
You can find my information here:
http://hi.csdn.net/gentalguo

Each information is authentic, I promise :)
And you can find my email address there. And I registered a MSN with that email.
You can contact me with email or MSN.

My suggestion? Well, little girl, nothing special. Sometimes, maybe somethings make you feel upset, at that moment, tell yourself~~oh, easy, easy, calm down~~:)
And never give up. Ask someboby who know those things well. Finally, you can make everything clear.
Oh, I have no idea what the time is in Seattle?~~Now is 4 PM in Beijing, and it's rainny today~~ :(


玉石玲珑 2011-04-22
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 gentalguo 的回复:]
Wow~~
Little girl, I'm glad to hear you have submited your homework.
However, maybe, study hard and make progress everyday is the only right choice~~
Hope you can finish your job without anyone's h……
[/Quote]
Thanks gentalguo~
Actually, i don't know your name, so just call you gentalguo! lol
you did give me a big help for my assignment! you very smart on it! =)
could you give me some suggestion how to be successful in the JAVA?

Sure, I will contact you in the future...but how?
How long have you been work? coz you call me little girl! lol
Can I ask your age??

Oh, I'm living Seattle Washington The US
Still the student right now!
玉石玲珑 2011-04-22
  • 打赏
  • 举报
回复
Thanks gentalguo~
Actually, i don't know your name, so just call you gentalguo! lol
you did give me a big help for my assignment! you very smart on it! =)
could you give me some suggestion how to be successful in the JAVA?

Sure, I will contact you in the future...but how?
How long have you been work? coz you call me little girl! lol
Can I ask your age??

Oh, I'm living Seattle Washington The US
Still the student right now!
戒指 2011-04-21
  • 打赏
  • 举报
回复
太乱了 ...
玉石玲珑 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 gentalguo 的回复:]
Only modified the class named TheOrder.
Replace that file.
OK, I have to attend a meeting, I'll back this afternoon.
[/Quote]

Oh! Got it! Nevermind! I did submit my homework!
Thanks for your help again!! =)

Anyway, where are you work at?
you english is good! atless u can understood what my assignment about!
玉石玲珑 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 gentalguo 的回复:]
Java code

public class TheOrder {

/**
*
*/
private static final long serialVersionUID = -5629754780352596207L;
private Vector<Rectangle> recVec = null;

// priva……
[/Quote]
thanks alot! it's just need to change TheOrder part??
Rectangle part don't need to change right??

If yes, I am going to submit my assignment now!!

one more question! I really want to give you a100 point! how can I do it?
gentalguo 2011-04-21
  • 打赏
  • 举报
回复
Only modified the class named TheOrder.
Replace that file.
OK, I have to attend a meeting, I'll back this afternoon.
gentalguo 2011-04-21
  • 打赏
  • 举报
回复

public class TheOrder {

/**
*
*/
private static final long serialVersionUID = -5629754780352596207L;
private Vector<Rectangle> recVec = null;

// private Vector<Color> colors = null;

public TheOrder() {
super();

init();

}

public void addWindow(Rectangle rect) {
if (rect != null) {
// here maybe have some problems, I have no idea about your request
recVec.add(rect);


}
}

public void click(Point p) {
if (p == null) {
throw new IllegalArgumentException();
}

if (recVec != null && recVec.size() > 0) {
for (int i = 0; i < recVec.size(); i++) {
Rectangle rect = recVec.get(i);

if (rect.containsPoint(p)) {
bringToFront(rect);
}
}
}
}

private void bringToFront(Rectangle rect) {
if (recVec.contains(rect) && recVec.indexOf(rect) != recVec.size() - 1) {
recVec.remove(rect);
recVec.add(rect);
}
}

private void init() {
recVec = new Vector<Rectangle>();

}



@Override
public String toString() {

StringBuffer sb = new StringBuffer();

for (int i = 0; i < recVec.size(); i++) {
Rectangle r = recVec.get(i);
sb.append(r.toString());
if (i != recVec.size() - 1) {
sb.append(",");
}
}
return sb.toString();
}



}

玉石玲珑 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 gentalguo 的回复:]
啰嗦几句哈,代码我替你写了,呵呵,今天心情还好。平时我可是从不帮人做作业的。
你就仔细体会一下,这道题目到底是希望你能够了解些什么,运用掌握些什么吧。
呵呵,没你想的那么困难,也没我之前想的那么复杂。

界面上我做过了,鼠标点可以,只是……呃,你那倒霉的老师给的宽高(6,8)太小,所以,你可以改大一点试试看。
[/Quote]

Could your fix the one you wrote?? I can't turn in this one becasue have GUI!!!!
You are right " 晕死,我还以为需要GUI界面展示出来,其实是没这个需求啊"
Could your fix it?? please...
cause the GUI one, we didn't study yet! that's why we can't use it!
Again, Thanks for your help!!! Thank you!
Also, I don't think need to use the graphic...

玉石玲珑 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 gentalguo 的回复:]
晕死,我还以为需要GUI界面展示出来,其实是没这个需求啊~~
罢了,罢了,反正我都写出来了,也不是很难,只不过是一些jdk自带的同名类不能用,要自己写而已。
代码给你吧。
三个类,拟老师给的那个用来测试。把我写的放到同一个package里面,记得自己加上package声明和import


Java code

public class Point {
int x = 0……
[/Quote]

Thank you so much! Thank you for your help!
"不需要GUI界面展示出来,其实是没这个需求." Yes, we don't need to use GUI!! We didn't learn there yet! Could your please help me to rewrite it??? Please.....because I can't turn in the one you write! My teacher may know it!
玉石玲珑 2011-04-21
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 blueskyluv 的回复:]
然后,这是老师给的
public class TheOrderTest {
public static void main( String [ ] args ) {
TheOrder myWindows = new TheOrder();

Point[] testPoints = new Point[ 3 ];
testPoints[0] = new Point……
[/Quote]
Thank you so much! Thank you for your help!
"不需要GUI界面展示出来,其实是没这个需求." Yes, we don't need to use GUI!! We didn't learn there yet! Could your please help me to rewrite it??? Please.....because I can't turn in the one you write! My teacher may know it!
gentalguo 2011-04-21
  • 打赏
  • 举报
回复
Wow~~
Little girl, I'm glad to hear you have submited your homework.
However, maybe, study hard and make progress everyday is the only right choice~~
Hope you can finish your job without anyone's help.

I'm just an ordinary programmer in Beijing.
You can contact me if you like.
What about you? Where are you?

This forenoon, I attended a meeting. But, it's diffcult to undertand some foreigner's speech~~
Ok, I have to start my work now.
玉石玲珑 2011-04-20
  • 打赏
  • 举报
回复
然后,这是老师给的
public class TheOrderTest {
public static void main( String [ ] args ) {
TheOrder myWindows = new TheOrder();

Point[] testPoints = new Point[ 3 ];
testPoints[0] = new Point( 2, 2 );
testPoints[1] = new Point( 3, 5 );
testPoints[2] = new Point( 5, 7 );

Rectangle[] testRects = new Rectangle[ 3 ];
testRects[ 0 ] = new Rectangle( testPoints[0], 6, 8 );
testRects[ 1 ] = new Rectangle( testPoints[1], 6, 8 );
testRects[ 2 ] = new Rectangle( testPoints[2], 6, 8 );

for( int i = 0; i< testRects.length; i++ ) {
myWindows.addWindow( testRects[i] );
}

System.out.println( "Original order of windows:" );
System.out.println( myWindows );

Point p1 = new Point( 4, 4 );
myWindows.click( p1 );
System.out.println( "After clicking point " + p1 + ":" );
System.out.println( myWindows );

myWindows.click( p1 );
System.out.println( "After AGAIN clicking point " + p1 + ":" );
System.out.println( myWindows );

Point p2 = new Point( 10, 10 );
myWindows.click( p2 );
System.out.println( "After clicking point " + p2 + ":" );
System.out.println( myWindows );

}
}

还有这个
Output from "crude test" for TheOrder

Original order of windows:"<(2,2),6,8>,<(3,5),6,8>,<(5,7),6,8>"

After clicking point (4,4):"<(3,5),6,8>,<(5,7),6,8>,<(2,2),6,8>"

After AGAIN clicking point (4,4):"<(3,5),6,8>,<(5,7),6,8>,<(2,2),6,8>"

After clicking point (10,10):"<(3,5),6,8>,<(2,2),6,8>,<(5,7),6,8>"

"<(3,5),6,8>,<(2,2),6,8>,<(5,7),6,8>,<(7,1),20,12>"

"<(3,5),6,8>,<(2,2),6,8>,<(5,7),6,8>,<(7,1),20,12>"
玉石玲珑 2011-04-20
  • 打赏
  • 举报
回复
对!原文是英文来的!我翻译的不好!!

TCSS 143 Spring 2011, Chapter 9 Programming Project 3, due 20 April

Main Idea:

Write a class named TheOrder that models a list of possibly overlapping rectangular two-dimensional window regions, like the windows for the programs open on your computer. The order of the rectangles in the list implies the order in which they would display on the screen (sometimes called the "z-order"), from 0 on the bottom to size() – 1 on the top.

Details:
Write a class named Rectangle. Each rectangle stores its (x,y) position, width, and height. The (x,y) position should be a Point as described below.

The class named Point is as we have used it before. See page 506 of textbook for description of Point class. You will have to implement the Point class for this project.

Your rectangle list class, TheOrder, will keep an ArrayList of Rectangles to implement the model of possibly overlapping rectangular two-dimensional window regions.

Your rectangle list class, TheOrder, should have a method that takes a Point as a parameter, treats it as though the user clicked that Point on the screen, and moves the topmost rectangle touching that Point to the front of the list, leaving the order of the rest of the list unchanged.

Write a class named TheOrderTest to test your code. This class contains only the main method which instantiates an object of type TheOrder, initializes it, and tests it. Make this test as complete as possible. Remember that we are using TheOrder to represent the z-order of a screen display.

Hand in:
Make a zip file of Point.java, Rectangle.java, TheOrder.java, and TheOrderTest.java.
噢噢噢噢 2011-04-20
  • 打赏
  • 举报
回复
lz火星来的?想帮你,但看不懂你再说啥.........
gentleboy2009 2011-04-20
  • 打赏
  • 举报
回复
乱的很啊
yuanxl33 2011-04-20
  • 打赏
  • 举报
回复
说真的我都没看懂题
gentalguo 2011-04-20
  • 打赏
  • 举报
回复
这是你翻译过的吗?
看不懂。
你的原题目是英文的?如果是英文的你还是把英文的原题贴出来吧……
mingxinhuang 2011-04-20
  • 打赏
  • 举报
回复
都是高人啊 哈哈
gentalguo 2011-04-20
  • 打赏
  • 举报
回复
啰嗦几句哈,代码我替你写了,呵呵,今天心情还好。平时我可是从不帮人做作业的。
你就仔细体会一下,这道题目到底是希望你能够了解些什么,运用掌握些什么吧。
呵呵,没你想的那么困难,也没我之前想的那么复杂。

界面上我做过了,鼠标点可以,只是……呃,你那倒霉的老师给的宽高(6,8)太小,所以,你可以改大一点试试看。
加载更多回复(1)

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧