講解:Fall Semester、Java、Rectangle殷勘、JavaJava|R

2018-2019 Fall Semester Lab Exercise A1Assignment4Design a class named Rectangle. The class contains:a. Five private data fields [10 points] x (double) : The x position of the center. In a valid rectangle, the range ofx is in (-10, 10) y (double) : The y position of the center. In a valid rectangle, the range ofy is in (-10, 10) width (double) : The width of the rectangle. In a valid rectangle, the rangeof width is in [0, 5] height(double) : The height of the rectangle. In a valid rectangle, the rangeof height is in [0, 5] color (java.awt.Color): The color of rectangle.b. Design three constructors: [10 points]1. A constructor with two parameters including x and y2. A constructor with four parameters including x, y, width and height.3. A constructor with seven parameters, the first four parameters are doubletype, which represent the x, y, width and height of current rectangle,and the last three parameters are integers, which represent the red, greenand blue value of current color respectively. If a rectangle has no width and height, in constructor method we need toset width=1 and height=1 as default value. If a rectangle has no color, in constructor method we need to set a defaultcolor whose red, green and blue value are all 100. For the third constructor, if the value of red green and blue are largerthan 255 or smaller than 0, we need to set it as its closest boundaryvalue.c. Design the getter and setter method for each private field of Rectangle. [10points]d. Design a toString() method, which can return a String value as followingoutput format. [10 points]The first test:public class Test1 {public static void main(String[] args) {Rectangle r1=new Rectangle(0,1,2,2,100,150,100);Rectangle r2=new Rectangle(3,1,3,1,-1,350,100);Rectangle r3=new Rectangle(2,2);Rectangle r4=new Rectangle(3,-1,2,2);System.out.println(r1);2018-2019 Fall Semester Lab Exercise A2System.out.println(r2);System.out.println(r3);System.out.println(r4);}}e. Design a public method named intersect() with a Rectangle parameter and areturn value (boolean). If the current rectangle is intersected with theparameter rectangle, it will return true, otherwise it will return false. [10points]f. Design a public static method named intersect() with two Rectangleparameters and a return value (boolean). If two rectangles are intersected, itwill return true, otherwise it will return false. [10 points]The Second Test:public class Test2 {public static void main(String[] args) {Rectangle r1=new Rectangle(0,0,2,2,100,50,100);Rectangle r2=new Rectangle(1.5,2,3,1,-1,350,100);Rectangle r3=new Rectangle(1.6,-1,1,3,50,100,200);Rectangle r4=new Rectangle(1,1,1,2,180,100,40);System.out.println(r1.intersect(r2));System.out.println(r1.intersect(r3));System.out.println(r1.intersect(r4));System.out.println(Rectangle.intersect(r3, r4));}}g. Design a public method named isValid() with a return value (boolean). Onlywhen the range of its width and height are in [0, 5] (0 and 5 are included) andCentre[0.0,1.0] Shape[2.0,2.0] Color[100,150,100]Centre[3.0,1.0] Shape[3.0,1.0] Color[0,255,100]Centre[2.0,2.0] Shape[1.0,1.0] Color[100,100,100]Centre[3.0,-1.0] Shape[2.0,2.0] Color[100,100,100]falsefalsetruetrue2018-2019 Fall Semester Lab Exercise A3the range of it x and y position are in (-10,10) (-10 and 10 are not included)代寫Fall Semester作業(yè)此再、代做Java編程語言作業(yè)、代寫Rectangle留學(xué)生作業(yè)劳吠、代做Java作業(yè) 幫做J, itwill return true, otherwise it will return false. [10 points]h. Design a public method named isInBoundary() with a return value (boolean).If the whole rectangle can be drawn in the screen (-10,10), it will return true,otherwise it will return false. [10 points]The third Test:Rectangle r1=new Rectangle(-2,1,5,5,100,150,200);Rectangle r2=new Rectangle(9,1,5,5,250,100,40);System.out.println(r1.isInBoundary());System.out.println(r2.isInBoundary()); ‘(The whole rectangle of the blue one can be drawn in the screen, so it is in boundary,but the orange one is not.)i. In same package, we create a class named RectangleTest, in which there is amain method. In main method, we will read several lines as following format.For each line, we need create an object of Rectangle according to the data inline. After that, we need to output all valid rectangles, which are not intersectwith the first valid rectangle in the line order. [10 points]The fourth Test:Sample input:2018-2019 Fall Semester Lab Exercise A49.27,6.61,3,7.18,209,144,2473.4,4.0,4.5,4.5,100,100,100-2.89,7.61,5.57,5.068.43,6.667.42,0.68,2.07,2.93,78,39,1656.70,1.54,3.52,3.121.14,0.76,2.37,3.07,236,105,1371.06,-0.80,3.03,2.66,132,120,2733.01,-9.08,2.76,2.36,138,148,119-0.51,-4.99,6.42,5.65-4.36,8.70,3.03,2.63,16,138,2219.40,2.41,6.47,4.90Sample output:j. Design a public method named draw() , in which we need to draw the currentrectangle in screen. We need to make sure that: [10 points] Only draw the valid rectangle. The rectangle in screen needs to have its color.In main method, adding following two statements, just before you using drawmethod.StdDraw.setXscale(-10,10);StdDraw.setYscale(-10,10);The fifth Test:Sample input:-4.98,-8.00,3.29,1.660.17,-8.00,2.37,3.434.04,-8.00,1.67,1.776.84,-8.00,3.35,3.30,87,9,2606.84,-4.03,2.20,2.83,200,139,786.84,-0.89,3.04,1.97,122,195,146.84,2.636.84,6.09,2.04,1.804.36,6.09Centre[8.4,6.7] Shape[1.0,1.0] Color[100,100,100]Centre[7.4,0.7] Shape[2.1,2.9] Color[78,39,165]Centre[1.1,-0.8] Shape[3.0,2.7] Color[132,120,255]Centre[3.0,-9.1] Shape[2.8,2.4] Color[138,148,119]Centre[-4.4,8.7] Shape[3.0,2.6] Color[16,138,221]2018-2019 Fall Semester Lab Exercise A50.64,6.09,3.07,3.25,-10,299,288-2.28,6.09,2.56,3.22-5.19,6.09,1.68,2.37,-20,-30,184-5.19,3.68,3.11,2.34-5.19,-0.82-5.19,-4.86,2.67,2.99,129,7,49Sample output:Sample input:-1.96,-8.00,2.99,-2.39,230,119,1482.80,-8.007.23,-8.00,2.44,3.207.23,-4.07,2.63,2.04,241,27,2677.23,0.57,8.84,1.987.23,5.917.23,9.18,-2.15,2.263.26,9.181.15,9.18,1.86,2.16,69,204,101-2.51,9.18,2.52,3.41-5.18,9.18,-1.02,3.172018-2019 Fall Semester Lab Exercise A6-6.18,6.75,-2.51,2.22,81,26,176-7.18,2.01,2.43,2.88,116,85,169-8.18,-1.42Sample output:What to submit1. Please submit three “.java” files including “Rectangle.java”“RectangleTest.java” and “StdDraw.java”, and make sure thatthose “.java” files have no package information included. Rectangle.java: It is for you to create and edit all questions. RectangleTest.java: It is for you to add necessary code to finish question i, and do not remove other code in this file. StdDraw.java: You can do no change about this file, but do not forget to remove package information if you added it.2. Please submit those three files into sakai website before deadline轉(zhuǎn)自:http://ass.3daixie.com/2018112013362282.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末引润,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子痒玩,更是在濱河造成了極大的恐慌淳附,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,265評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蠢古,死亡現(xiàn)場離奇詭異奴曙,居然都是意外死亡,警方通過查閱死者的電腦和手機草讶,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,078評論 2 385
  • 文/潘曉璐 我一進(jìn)店門洽糟,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人堕战,你說我怎么就攤上這事坤溃。” “怎么了嘱丢?”我有些...
    開封第一講書人閱讀 156,852評論 0 347
  • 文/不壞的土叔 我叫張陵薪介,是天一觀的道長。 經(jīng)常有香客問我越驻,道長汁政,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,408評論 1 283
  • 正文 為了忘掉前任缀旁,我火速辦了婚禮记劈,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘并巍。我一直安慰自己目木,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 65,445評論 5 384
  • 文/花漫 我一把揭開白布懊渡。 她就那樣靜靜地躺著嘶窄,像睡著了一般。 火紅的嫁衣襯著肌膚如雪距贷。 梳的紋絲不亂的頭發(fā)上柄冲,一...
    開封第一講書人閱讀 49,772評論 1 290
  • 那天,我揣著相機與錄音忠蝗,去河邊找鬼现横。 笑死,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的戒祠。 我是一名探鬼主播骇两,決...
    沈念sama閱讀 38,921評論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼姜盈!你這毒婦竟也來了低千?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,688評論 0 266
  • 序言:老撾萬榮一對情侶失蹤馏颂,失蹤者是張志新(化名)和其女友劉穎示血,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體救拉,經(jīng)...
    沈念sama閱讀 44,130評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡难审,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,467評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了亿絮。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片告喊。...
    茶點故事閱讀 38,617評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖派昧,靈堂內(nèi)的尸體忽然破棺而出黔姜,到底是詐尸還是另有隱情,我是刑警寧澤蒂萎,帶...
    沈念sama閱讀 34,276評論 4 329
  • 正文 年R本政府宣布秆吵,位于F島的核電站,受9級特大地震影響岖是,放射性物質(zhì)發(fā)生泄漏帮毁。R本人自食惡果不足惜实苞,卻給世界環(huán)境...
    茶點故事閱讀 39,882評論 3 312
  • 文/蒙蒙 一豺撑、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧黔牵,春花似錦聪轿、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,740評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至金赦,卻和暖如春音瓷,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背夹抗。 一陣腳步聲響...
    開封第一講書人閱讀 31,967評論 1 265
  • 我被黑心中介騙來泰國打工绳慎, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 46,315評論 2 360
  • 正文 我出身青樓杏愤,卻偏偏與公主長得像靡砌,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子珊楼,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,486評論 2 348

推薦閱讀更多精彩內(nèi)容