Question: Implement the following two Java classes. Zn encapsulates the elements of the ring Zn, integers modulo n. Complex encapsulates the complex numbers. public class Zn
Implement the following two Java classes. Zn encapsulates the elements of the ring Zn, integers modulo n. Complex encapsulates the complex numbers.
public class Zn extends Ring {
public static int n;
// construct a Zn element from integer
public Zn(int a)
// return a string in the form [3]
public String toString() }
public class Complex extends Field {
// construct the complex number x + yi
public Complex(double x, double y)
// return a string in the form -3+4i
public String toString()
}
The Ring and Field classes are defined as:
public abstract class Ring {
public abstract Ring add(Ring other);
public abstract Ring sub(Ring other);
public abstract Ring mul(Ring other);
}
public abstract class Field extends Ring
{
public abstract Field div(Field other);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
