Create a point class that contains x and y coordinates

Assignment Help JAVA Programming
Reference no: EM131445041

Java Assignment

Hello, Here is my anwer I just want you to order them in a file, and send it to me by zipping file. Also the code and the out put should be working well:

JAVA

Composition and Encapsulation - The Line and Point Class

Points and Lines ( Here is the Image's Link : https://e.top4top.net/p_4407a55b1.png ).

Computer graphics systems make use of two general rendering systems - rasters and vectors -- to produce images. Raster systems keep track of collections of individual pixels and vector systems keep track of lines. (Lines are more accurate, but require more computer resources.)

This assignment calls for a Line object that represents a graphically depicted image on the screen. This object must store this data:

_Endpoint objects (x and y coordinates as an integer). There will be two of these.
_The line color as a String
_The line width as an integer

Note that the Line object must be composed of two Point objects.

The Point Class

Create a Point class that contains x and y coordinates (x and y are integers) that represents a point in two-dimensional space. A point can lie only in the first quadrant in the x-y coordinate axis.

Include the following methods

_two constructors: a default that initializes x and y to 0, and another that accepts the x and y values as passed-in parameters
_get and set methods to retrieve and assign coordinate values
_a toString method that will return a String containing the coordinates of the point formatted as (x, y)
_an equals method (returns a boolean value) that compares two Points for equality. This method takes a single parameter of type Object and will cast the Object into a Point for comparison.
_anything else you deem necessary

The Line Class

Create a Line class that contains variables and/or methods to represent

_the end Points of the line (be sure your Point objects are declared as private)
_the length of the line (represent this as a return value from a method)
_color
_width

This Line class should have the following methods

_A default constructor that creates Points that represent a zero-length black line at the origin with a width of 1 pixel
_A constructor that accepts four ints - x and y for point 1 and x and y for point 2, a color and a width
_A constructor that accepts four ints (color defaults to black and width to 1 pixel)
_get and set methods to retrieve values and assign values as you deem necessary
_A toString method that prints the coordinates of the line endpoints, the length, the color and width of the line (nicely formatted, please)
_an equals method (returns a boolean value) that will compare two lines for equality. Two lines are equal if their endpoints, width and color are the same. Note that Points do not need to be in same order. Be sure and use the equals method you wrote from your Point class to compare Points. Your equals method should override the equals method in Object.
_a validateLine method that will make sure the points are in the first quadrant. This method must be declared as static -- so that it can be called without an instance of the class.

Create a driver class called LineDriver that will work with two lines. Create both lines as zero-length at the origin. Then provide a menu that is displayed repetitively with the following options:

1 - Enter coordinates, width and color for first line (line should be validated as part of this process -- use the validateLine method -- do not continue until valid coordinates and width are obtained from the user)

2 - Enter coordinates, width and color for second line (ditto)

3 - Compare the two lines (specify if lines are equal/not equal after comparison)

4 - Display coordinates, width, length and color for first line (the length should be derived from the coordinates using the distance formula and is represented as a real number with 2 post-decimal positions of precision.)

5 - Display coordinates, width, length and color for second line (the length should be derived from the coordinates using the distance formula and is represented as a real number with 2 post-decimal positions of precision.)

6 - Quit

Reference no: EM131445041

Questions Cloud

Define eriksons concepts of mal-development and malignancy : Define Erikson's concepts of mal-development and malignancy.  Why are these bad for your personality?  How can these conditions be corrected (be specific)
Determination of an equilibrium constant : Determination of an equilibrium constant by using a spectrophometer 1 In part 1 of this experiment how are solution of unknown Fe(SCN)2+ made? 2 in part 2 of this experiment,why are approximately equal concentration of the reactants,Fe3+ and SCN, ..
Develop a evaluation of a recent business decision : Develop a evaluation of a recent business decision in your work or desired career. Include the following:Discuss the influence the decision-making process had on the outcome.Evaluate the effectiveness of the process. What stages were most challengi..
Find the molecular formula of formic acid : Formic acid is responsible for the sting you feel when stung by fire ants. By mass, formic acid is 26.10% C, 4.38% H, and 69.52% O. The molar mass of formic acid is 46.02 g/mol. Find the molecular formula of formic acid and draw its Lewis struc..
Create a point class that contains x and y coordinates : Create a Point class that contains x and y coordinates (x and y are integers) that represents a point in two-dimensional space. A point can lie only in the first quadrant in the x-y coordinate axis.
What is the employee benefit : What is the employee benefit? For how long? Are there benefits for part-time workers? Are there benefits for both caregivers? Would this include adoption? Fostering
How would you go about handling : As the HR Director of a large health system, you are beset with a wide variety of difficult situations. You have been served notice by a union representative that they are expecting contract negotiations to start and therefore you need to start pr..
Mass percent concentration of a solution : You can practice converting between the mass of a solution and mass of solute when the mass percent concentration of a solution is known. The concentration of the KCN solution given in Part A corresponds to a mass percent of 0.334 %.
Describe the purpose of the database : Suppose a local college has tasked you to develop a database that will keep track of students and the courses that they have taken. In addition to tracking the students and courses, the client wants the database to keep track of the instructors te..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a java application that allows user to play blackjack

Write a Java application that allows a user to play Blackjack against the computer. The computer will act as the house, dealing the cards and paying when you win.

  Write a java program to simulate a calculator

Write a JAVA program to simulate a calculator. Your program should take two numbers and an operator (+,-,*,or/), from the user in the following format: number1 operator number2 (For example 5.6 + 7.2) and print the result.

  Discuss the types of java exceptions

Discussion Question: Discuss the types of Java exceptions that can be thrown and the best ways to handle them

  Write the bubble sort

The village of Marengo conducted a census and collected records that have household data, including the number of occupants in each household.

  Write a program that prompts the user to enter an integer

Using && and || write a program that prompts the user to enter an integer and determine whether it is: Evenly divisible by 5 AND 6.

  In this project you need to write a program called

in this project you need to write a program called ecc.javato implement elliptic curve

  Write a program that prompts the user to enter a b c

Write a program that prompts the user to enter a,b,c,d,e, and f and displays the result. If ad-bc is 0, report that "The equation has no solution."

  Create a class called scorelist according to the uml diagram

Create a class called ScoreList according to the UML diagram. This class will allow a user to enter up to 100 scores into an array.

  How array is declared and initialized in java

What is a Java applet - how array is declared and initialized in Java and what are the access control attributes in Java?

  Compare the average completion times of all jobs

Compare the average completion times of all jobs for each scheduling algorithm. Output the details of each algorithm's execution. You need to show which jobs are selected at what times as well as their starting and stopping burst values. You can choo..

  Writing a program to calculate state income tax

The second programming project involves writing a program to calculate state income tax for a single taxpayer that uses a GUI. The GUI should use the grid layout manager and should looks similar to the following: The salary income, interest income..

  Write the classic arcade game of breakout

For each instance variable in your program, explain why you chose to make it an instance variable rather than a local variable - How did you test whether the game would end correctly in this second case? Did you make any changes to the code when test..

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