![wolfking800](/avatars/31504.jpg)
wolfking800
28.02.2020 •
Engineering
Public class Point { public float x; public float y; public float z; public Point(int inX, int inY, int inZ) { x = inX; y = inY; z = inZ; } } In the client code, ArrayList is created, and 3 points are added to it: import java.util.ArrayList; import java.util.Collections; public class Lab6Main { public static void main(String[] args) { ArrayList Points = new ArrayList(); Points.add(new Point(1, 2, 3)); Points.add(new Point(0, 0, 0)); Points.add(new Point(0, 34, 68)); //Collections.sort(Points); } } 1. Create 2 files – Point.java and Lab6Main.java for Point class and client code; copy the code. Compile and run the project.
Solved
Show answers
More tips
- H Health and Medicine Contraceptive Pills After 35: The Importance Of Choosing The Right Medication...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- C Computers and Internet How to Learn to Type Fast?...
- A Art and Culture Who Said The Less We Love a Woman, the More She Likes Us ?...
- F Family and Home How to Get Rid of Your Neighbors?...
- S Society and Politics How Could Nobody Know About the Dead Mountaineers?...
- H Health and Medicine How to Cure Adenoids?...
Answers on questions: Engineering
- E Engineering Describe two criteria a student can use when determining which college or university to attend....
- E English Define each of the following art elements. 1. Line 2. Shape 3. Form 4. Color 5. Value 6. Space 7. Texture...
- C Chemistry Determine the mass of iron (III) oxide (Fe2O3) produced one the decomposition reaction of 100.0 grams of iron (III) hydroxide (Fe(OH)3)...
- B Business 1. Briefly describe the environmental and organizational changes that have taken place over the past 25 years that have affected the nature of work and careers. In a broad...
- M Mathematics Carl feeds his dog 2 1/2 cups of dog food every day. Each bag contains 64 cups of dog food. What is the maximum number of days that carl can feed his dog exactly 2 1/2 cups...
- H History The GI Bill provided all the following benefits except?...
- B Business Let s say that our country s Gross Domestic Product is at $15 billion (this year). We also know that we currently have unemployment and that we would have full employment...
- P Physics What happens to the magnitude of the charge on each plate of a capacitor if the potential difference between the conductors is doubled?...
- M Mathematics What is a word problem for this equation 3 1/2 / 7x equals 7/2 * 8/7 equals 56/14 equals 4...
- M Mathematics What is the unit rate of 49 points in 7 games...
Ответ:
/*Lab6Main.java */
import java.util.ArrayList;
import java.util.Collections;
public class Lab6Main {
public static void main(String[] args) {
ArrayList<Point> Points = new ArrayList<Point>();
Points.add(new Point(1, 2, 3));
Points.add(new Point(0, 0, 0));
Points.add(new Point(0, 34, 68));
Points.add(new Point(0, 34, 68));
Collections.sort(Points, new NewComparator());
for (int i=0;i < Points.size();i++){
System.out.println(Points.get(i).x + " " + Points.get(i).y + " " + Points.get(i).z);
}
}
}
/*Point.java */
public class Point {
public float x;
public float y;
public float z;
public Point(int inX, int inY, int inZ)
{
this.x = inX;
this.y = inY;
this.z = inZ;
}
}
/*NewComparator.java */
import java.util.Comparator;
class NewComparator implements Comparator<Point> {
@Override
public int compare(Point point01, Point point02) {
if(point01.x != point02.x)
return (int)(point01.x - point02.x);
else if(point01.y != point02.y)
return (int)(point01.y - point02.y);
else if(point01.z != point02.z)
return (int)(point01.z - point02.z);
/*No Swap Required */
return 0;
}
}
Explanation:
Ответ:
Spinach is a leafy, green vegetable. It is one of the most nutritious foods on earth. Here is detailed health and nutrition information about spinach. Broccoli is a popular vegetable that is high in many nutrients, including fiber and vitamin C.