Write a test program that creates a myrectangle2d

Assignment Help Computer Engineering
Reference no: EM133959002

Introduction to Computer Science

Question 1. The following assignment question refers to "10.5 Case Study: Designing the Course Class" in your textbook.

Revise the methods, draw the UML diagram and write a test program that tests all the revised and added methods and displays the students in the course after each test as described in the programming exercise 10.9.

** 10.9 (The Course class) Revise the Course class as follows:
Revise the getStudents ( ) method to return an array whose length is the same as the number of students in the course. (Hint: create a new array and copy students to it.)
The array size is fixed in Listing 10.6. Revise the addStudent method to automatically increase the array size if there is no room to add more students. This is done by creating a new larger array and copying the contents of the current army to it.
Implement the dropStudent method.
Add a new method named cl ear ( ) that removes all students from the course.
Write a test program that creates a course, adds three students, removes one, and displays the students in the course.

Question 2. Define the MyRectangle2D class that contains the following data fields and methods, draw the UML diagram for the class then implement the class. Write a test program that creates a MyRectangle2D object rl and do all the activities as described in the programming exercise

10.13.
* 10.1 3 (Geometry: the MyRec t angle2D class) Define the MyRect angl e2D class that contains:
Two doubt e data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to x- or y-axis.)
The data fields width and height with getter and setter methods.
A no-arg constructor that creates a default rectangle with (0, 0) for (x. y) and 1 for both width and height.
A constructor that creates a rectangle with the specified x. y. width, and height.
A method getArea ( ) that returns the area of the rectangle.
A method getPeri meter ( ) that returns the perimeter of the rectangle.
A method contai ns (doubl e x. double y) that returns true if the specified point (x, y) is inside this rectangle (see Figure 10.24a).
A method contai ns (MyRectangl e2D r) that returns t rue if the specified rectangle is inside this rectangle (see Figure 10.246).
A method overlaps (MyRectangl r) that returns t rue if the specified rectangle overlaps with this rectangle (see Figure 10.24c).

10.2 1 (Divisible by 5 or 6) Find the first It) numbers greater than Long . MAX_VALUE that are divisible by 5 or 6.
(a) (b) (c) (d)

815_Figure.jpg

 

FIGURE 10.24 A point is inside the rectangle. (b) A rectangle is inside another rectangle. (c) A rectangle overlaps another rectangle. (d) Points are enclosed inside a rectangle. Get AI-free online assignment help from experienced academic experts.

Draw the UML diagram for the class then implement the class. Write a test program that creates a MyRectangle2D object r1 (now MyRectangle2D (2. 2. 5.5 , 4 . 9 ) ), displays its area and perimeter. and displays the result of r1. contai ns (3 , 3), r1 contai ns (new MyRectangle2D(4 , 5, 10 .5, 3 .2) hand rl .overlaps (now MyRectangl e2D (3 , 5, 2.3, 5.4) ).

Question 3. Write a Java program as described in the programming exercise 10.21. Hint: Use BigIntemr class.

10.2 1 (Divisible by 5 or 6) Find the first It) numbers greater than Long . MAX_VALUE that are divisible by 5 or 6.

Reference no: EM133959002

Questions Cloud

Discuss the 1721 mexican revolution : Provide ten clear discussion points on the 1721 mexican revolution. Identify 5 key things that happened and affected american and their economic well being.
Discuss a 1722 brazilian revolt : Discuss a 1722 brazilian revolt and explain ten key contributions of the war to american population. Use three relevant example to justify your answers.
Describe the difference between imperialism and expansionism : Using Lenin's description of an imperialistic event, describe the difference between imperialism and expansionism.
Summary of 16 th and 19th century political and economic war : Give a clear summary of 16 th and 19th century political and economic war and developments in both america and mexico.
Write a test program that creates a myrectangle2d : COSC1047 Introduction to Computer Science II, Algoma University College - Write a Java program as described in the programming exercise
Majority of federal funding focus on programs : Is childhood obesity a major public health concern in America. Should the majority of federal funding focus on programs
Why were several of old and new countries economically : Why were several of old and new countries economically and politically unfit. Group the database between federalists and centaralist.
Have you been to any type of historical marker : Have you been to any type of historical marker? For example, Dealey Plaza in Dallas, or maybe you've been outside Texas to someplace like Coloma.
Explain roles played by mongol in rise and fall of west : What are the political, social and economic problems further spread european interest exploration. Use relevant examples to support your answer.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd