Please explain what\'s Zombie Process.
Solution
zombie process is a process state when the child dies before the parent process,
in this case the structural information of the process is still in the process table.
when a process finishes execution,it will have an exit status to report to its parent process.
because of this last little bit of information,the process will remain in the operating system\'s
process table as a zombie process.indicating that it is not
to be schedule for further execution,but that it cannot be completly removed untill it has been
determined that the exit status is no longer needed..
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
Read carefully. Im not sure if the point class is correct but postin.pdf
1. Read carefully. Im not sure if the point class is correct but posting it too.
In this program, you are to write 3 different classes that should work together as aggregate
classes (“has-a”relationship) and using inheritance (“is-a” relationship). It will also use your
knowledge of .equals methods, constructors, and deep vs. shallow copies. The classes you
should implement are:
1.Point – this should be the same Point.java that you have already implemented in MinilabPoint.
Later, it will beused as part of an aggregate class called Ray (a Ray “has-a” Point as part of its
data – see below for details onRay).
2. Ray – this will implement a Mathematical Ray. It should have the following:
Data: That hold an endpoint (as a Point) and a direction (as an int that stores the number of
degrees fromthe x-axis). that hold the x-value and the y-value. This data will be eventually be
inherited by asubclass (see below) and should not be public. Examples of Rays are shown below:
One Ray has an endpoint of the Point (2, 3) and a directionof 45 (since it is a 45º angle with the
x-axis).The other Ray has an endpoint of the Point (0, 0) and adirection of 135 (since it is a 135º
reference angle with the x-axis).
Constructors: A default constructor that will initialize the endpoint to a new Point that is (3, 4)
and the direction
to 135. A parameterized constructor that will receive the endpoint (as a Point) and the direction
(as an int). If the direction is not between 0 and 359 (inclusive), thenthrow new
IllegalArgumentException(<”your descriptive String here”>);If the direction is OK, then
initialize the data to what is received. Be sure a deep copy is used. A copy constructor that will
receive another Ray. It should initialize its data to be the same as the
Ray that was received. Be sure a deep copy is used.
Methods: A toString() method that returns a String representing the Ray. It should be in the
form endpoint-----> direction Example: (3, 4)----->135It is using 5 dashes, a >, and a
space. Be exact.
A method called translate(int xmove, int ymove) that will return nothing and “translates,” or
shifts,
the endpoint by the distances passed in.
A method called rotate(int angle), which will receive an angle and return nothing. If the
anglereceived is negative, it should:throw new IllegalArgumentException(<”your descriptive
String here”>);
If the angle is OK, then it should change the direction by adding the angle to it. But…if that
makes the direction be >= 360, then the method should change it to be from 0-359. For
2. example:If (3, 4)----->135 is told to rotate(800) then its direction will change to 835. But
that isactually twice around the circle and ending up at 935. So it should be corrected to finally
be: (3, 4)----->215
A method called equals(Object obj), which receives an Object and returns true if it’s endpoint
and
its direction are both equal to the endpoint and direction of the Object (Ray) that was received.
Itshould be implemented like we did in class.
A method called getEndpoint, which receives nothing and returns the endpoint (as a Point).
Besure it returns a deep copy. A method called setEndpoint(Point p), which receives a Point
and returns nothing. It should set itsendpoint to a deep copy of what is received.
A method called aboveXAxis(), which returns a boolean that will be true if any part of the
Rayextends to above the x-axis (in Quadrant 1 or Quadrant 2).
3. StyleRay – this will be a subclass of Ray and will also store what it looks like as a String
(either “dashed”,
“dotted”, or “double”). Data:
It will also have an endpoint (as a Point) and a direction (as an int). Both of those are
justinherited from the parent class. In addition, StyleRay should have a String which holds the
style(either “dashed”, “dotted”, or “double”).Constructors: Since constructors are not inherited,
you will have to implement these constructors. Insome cases they work similarly to the parent
class’s constructors. A default constructor that will initialize the endpoint to a new Point that is
(3, 4) and the directionto 135 (same as its parent class). In addition, it will initialize its style to
“double”.
A parameterized constructor that will receive the endpoint (as a Point) and the direction (as an
int)and the style (as a String). If the direction is not between 0 and 359 (inclusive), thenthrow
new IllegalArgumentException(<”your descriptive String here”>);Also, if the style that is
received is not equal to “double” or “dashed” or “dotted” thenthrow new
IllegalArgumentException(<”your descriptive String here”>);If the direction and style are OK,
then initialize the data to the Point, int, and String that arereceived. Be sure a deep copy is used.
A copy constructor that will receive another StyleRay. It should initialize its data to be the same
as the StyleRay that was received. Be sure deep copies are used.
Methods: Almost every StyleRay method can be inherited except for the following
A toString() method which will receive nothing and return a String representing the
StyleRay.Depending on the type, the String representation will look like this:
If the style equals “double” it should be endpoint=====> direction
Example: (3, 4)=====> 135It is using 5 equal signs, a >, and a space. Be exact.
If the style equals “dotted” it should be endpoint…..> direction
3. Example: (3, 4)…..> 135It is using 5 dots, a >, and a space. Be exact.
If the style equals “dashed” it should be endpoint- - -> direction
Example: (3, 4)- - -> 135It is using 3 dashes with a space between each, then a > and aspace.
Be exact.
If the style is anything but the above, something is wrong. It should not happen, but youcan use
a last else in your logic and:throw new IllegalStateException(<”your descriptive String here”>);
A method called equals(Object obj), which receives an Object and returns true if it’s endpoint
and
its direction are both equal to the endpoint and direction of the Object (StyleRay) that was
received. NOTE that it does not check to see if the styles are the same. It should be
implemented like wedid in class.
Point Class:
class Point {
// integers set to private
private int x;
private int y;
//default constructor
public Point ()
{
x=4;
y=-2;
}
//parameterized constructor
public Point (int x, int y)
{
this.x=x;
this.y=y;
}
//Copy Constructor
public Point (Point p)
{
this.x=p.x;
this.y=p.y;
}
//which receives nothing and just returns the x value. (This
//is an example of a “getter,” or “accessor” method)
4. int getX()
{
return this.x;
}
//receives an int and sets its x value to
//what is received.
void setX(int newX)
{
this.x=newX;
}
// Inquadrant which returns
//true if the current instance is in theQuadrant,
//false otherwise. The quadrants are defined like in Math and do not
//include the axes themselves
boolean inQuadrant(int theQuadrant)
{
switch(theQuadrant)
{
case 1 :
if(this.x>0 && this.y>0)
{ return true;
}
break;
case 2 :
if(this.x<0 && this.y>0)
{ return true;
}
break;
case 3 :
if(this.x<0 && this.y<0)
{
return true;
}
break;
case 4 :
if(this.x>0 && this.y<0)
5. {
return true;
}
break;
default :
//If theQuadrant is not in the range 1-4.
throw new IllegalArgumentException("Quadrant should be 1,2,3 or 4.. "
+ "You have entered quadrant as "+theQuadrant);
} return false;
}
void translate(int xmove,int ymove)
{
this.x=this.x+xmove;
this.y=this.y+ymove;
}
// String representing the
//current instance
@Override
public String toString()
{
return "(" + this.x + ", " + this.y + ")";
}
//returns true
@Override
public boolean equals(Object obj) {
if(obj instanceof Point){
Point p = (Point)obj;
if(x == p.x && y == p.y)
return true;
}
return false;
}
}
Solution
6. I used the same Point class provided.
PROGRAM CODE:
Ray.java
package math;
public class Ray {
private Point endPoint;
public int direction;
protected int x;
protected int y;
Ray()
{
endPoint = new Point(3,4);
direction = 135;
}
Ray(Point endPoint, int direction)
{
this.endPoint = new Point(endPoint);
if(direction >=0 && direction<=359)
{
this.direction = new Integer(direction);
}
else throw new IllegalArgumentException("Direction is out of range");
}
Ray(Ray other)
{
this.endPoint = new Point(other.endPoint);
this.direction = new Integer(other.direction);
}
@Override
public String toString() {
// TODO Auto-generated method stub
return endPoint + "-----> " + direction;
7. }
void translate(int xmove, int ymove)
{
endPoint.translate(xmove, ymove);
}
void rotate(int angle)
{
if(angle<0)
throw new IllegalArgumentException("Angle is negative");
else
{
direction += angle;
while(direction >= 360)
{
direction -= 360;
}
}
}
@Override
public boolean equals(Object obj) {
if(obj instanceof Ray)
{
Ray ray = (Ray) obj;
if(endPoint.equals(ray.endPoint) && ray.direction == direction)
{
return true;
}
}
return false;
}
public Point getEndpoint()
{
8. return endPoint;
}
public void setEndpoint(Point p)
{
endPoint = new Point(p);
}
public boolean aboveXAxis()
{
if(endPoint.inQuadrant(1) && endPoint.inQuadrant(2))
return true;
else return false;
}
}
StyleRay.java
package math;
public class StyleRay extends Ray{
String style;
public StyleRay() {
super();
this.style ="double";
}
StyleRay(Point endPoint, int direction, String style)
{
super(endPoint, direction);
if(style.equals("double") || style.equals("dashed")||style.equals("dotted"))
this.style = new String(style);
}
StyleRay(StyleRay other)
{
this(other.getEndpoint(), other.direction, other.style);
}
9. @Override
public String toString() {
if(style.equals("double"))
return getEndpoint() + "=====> " + direction;
else if(style.equals("double"))
return getEndpoint() + ".....> " + direction;
else if(style.equals("double"))
return getEndpoint() + "- - -> " + direction;
else throw new IllegalArgumentException("Invalid style");
}
@Override
//Super class - Ray does the same job which is required here
public boolean equals(Object obj) {
if(obj instanceof StyleRay)
{
StyleRay styleray = (StyleRay)obj;
Ray ray = new Ray(styleray.getEndpoint(), styleray.direction);
return super.equals(ray);
}
return false;
}
}
Tester.java
package math;
public class Tester {
/**
* @param args
*/
public static void main(String[] args) {
Ray ray1 = new Ray();
System.out.println(ray1);
Ray ray2 = new Ray(new Point(5,5), 110);
System.out.println(ray2);