Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ace11c

Browse files
authoredFeb 24, 2023
Add files via upload
1 parent db238a3 commit 8ace11c

19 files changed

+3170
-0
lines changed
 

‎ArbitraryFloatingPointNumbers.java

Lines changed: 312 additions & 0 deletions
Large diffs are not rendered by default.

‎ArbitraryWholeNumbers.java

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/**
2+
* A class that represents Arbitrary Whole Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public class ArbitraryWholeNumbers extends ArbitraryFloatingPointNumbers {
7+
8+
// A boolean field that indicates whether the number is less than 0 or not
9+
private boolean isNegative;
10+
// An array that stores the digits of the floating point number
11+
private int[] digits;
12+
13+
/**
14+
* Creates an Arbitrary Whole Number.
15+
* Assigns the class's fields the values that the constructor got when a Arbitrary Whole Number object is created.
16+
* Passes the fields to the superclass (Arbitrary Floating Point Number).
17+
* @param isNegative A boolean indicating whether the current number is negative or not
18+
* @param digits An array that represents the digits of an arbitrary floating point number
19+
*/
20+
public ArbitraryWholeNumbers(boolean isNegative, int[] digits) {
21+
super(isNegative, digits);
22+
this.isNegative = isNegative;
23+
this.digits = digits;
24+
}
25+
26+
/**
27+
* Determines whether the current arbitrary whole number is negative or not.
28+
* Returns true if the current number is negative.
29+
* Returns false if the current number is NOT negative.
30+
* @return A boolean that indicates whether the current number is negative.
31+
*/
32+
public boolean isNegativeNumber() {
33+
if (isNegative)
34+
return true;
35+
else
36+
return false;
37+
}
38+
39+
/**
40+
* An overridden toString method that creates the string representation of an arbitrary whole number given.
41+
* @return A string that is the proper string representation of an arbitrary whole number given
42+
*/
43+
public String toString() {
44+
StringBuilder result = new StringBuilder();
45+
// Append '-' sign to the beginning of the number if the number is negative
46+
if (this.isNegative == true) {
47+
result.append('-');
48+
}
49+
// A new array that is same as digits but has all leading zeros removed.
50+
int[] array = removeLeadingZero(digits);
51+
// Append every element of the array that has all leading zeros removed to the resulting string
52+
for (int i = (array.length - 1); i >= 0; i--) {
53+
result.append(array[i]);
54+
}
55+
return result.toString();
56+
}
57+
58+
/**
59+
* A helper method to remove leading zeros.
60+
* @param array Any given int array that needs its leading zeros removed
61+
* @return An array that has all its leading zeros removed
62+
*/
63+
public int[] removeLeadingZero(int[] array) {
64+
// A variable that stores the numbers of leading zeros
65+
int numLeadingZero = 0;
66+
// A variable that stores whether the current digit in the array is a non-zero
67+
boolean isNonZero = false;
68+
// A variable storing the index for the following 'while' loop
69+
int i = array.length - 1;
70+
/* A loop that determines the number of leading zeros.
71+
* The nonZero variable will also be set when the first non-zero is met to indicates the end of loop
72+
* Condition: The index must be more than or equal to 0 and the isNonZero variable must be FALSE
73+
*/
74+
while (i >= 0 && !isNonZero) {
75+
if (array[i] == 0) {
76+
numLeadingZero++;
77+
isNonZero = false;
78+
i--;
79+
}
80+
else
81+
isNonZero = true;
82+
}
83+
// A variable that stores the length of the new array
84+
int newLength = array.length - numLeadingZero;
85+
// An array of type int that stores the new array
86+
int[] newArray = new int[newLength];
87+
// A variable storing the index of the old (given) array
88+
int index1 = array.length - numLeadingZero - 1;
89+
// A variable storing the index of the new array
90+
int index2 = newArray.length - 1;
91+
/* A loop that copies every element from old, original array to the new array
92+
* Condition: index of both arrays must be more than or equal to 0
93+
*/
94+
while (index1 >= 0 && index2 >= 0) {
95+
newArray[index2] = array[index1];
96+
index1--;
97+
index2--;
98+
}
99+
return newArray;
100+
}
101+
102+
/**
103+
* A helper method that converts all arrays to strings.
104+
* @param array Any given arrays of type int
105+
* @return A String that is the string representation of the given array
106+
*/
107+
public String arrayToString(int[] array) {
108+
// A variable of type StringBuilder that stores the output string
109+
StringBuilder output = new StringBuilder();
110+
/* A loop that appends every element of the given array into the output string
111+
* Condition: index must be less than length of array */
112+
for (int i = 0; i < array.length; i++) {
113+
if (array[i] != 0)
114+
output.append(array[i]);
115+
}
116+
return output.toString();
117+
}
118+
119+
/**
120+
* An overridden equals method that determines if two whole numbers are equal to each other
121+
* This can be done by comparing the contents of the two string representations of the two numbers
122+
* @param o Any given object
123+
* @return Returning true or false depending on these numbers' equality
124+
*/
125+
public boolean equals(Object o) {
126+
if (o instanceof ArbitraryWholeNumbers) {
127+
ArbitraryWholeNumbers number = (ArbitraryWholeNumbers) o;
128+
// A variable storing this number's digits with leading zeros removed
129+
int[] newArray1 = removeLeadingZero(this.digits);
130+
// A variable storing input, given number's digits with leading zeros removed
131+
int[] newArray2 = removeLeadingZero(number.digits);
132+
// A variable storing the string representation of this ArbitraryWholeNumbers
133+
String s1 = arrayToString(newArray1);
134+
// A variable storing the string representation of the given ArbitraryWholeNumbers
135+
String s2 = arrayToString(newArray2);
136+
return (this.isNegativeNumber() == number.isNegativeNumber() && s1.equals(s2));
137+
}
138+
return false;
139+
}
140+
141+
/**
142+
* A method to add two arbitrary whole numbers and return the string representation of the result
143+
* @param value1 Any given value of type ArbitraryWholeNumbers
144+
* @param value2 Any given value of type ArbitraryWholeNumbers
145+
* @exception UnsupportedOperationException Throw this exception when given input numbers have different signs
146+
* @return A new object of type ArbitraryWholeNumbers that has all the numbers added up
147+
*/
148+
public ArbitraryWholeNumbers add (ArbitraryWholeNumbers value1, ArbitraryWholeNumbers value2) {
149+
// A variable to keep track of the carry
150+
int carry = 0;
151+
// A variable to set the length of the array
152+
int length = 0;
153+
// Remove Leading Zeros of both input values
154+
// Array1 is a new array of type int that is the digits of value1 that has been removed all leading zeros
155+
int[] newArray1 = removeLeadingZero(value1.digits);
156+
// Array2 is a new array of type int that is the digits of value2 that has been removed all leading zeros
157+
int[] newArray2 = removeLeadingZero(value2.digits);
158+
/* Setting length of resulting array to the maximum length between the two newArrays.
159+
*/
160+
if (newArray1.length > newArray2.length)
161+
length = newArray1.length + 1;
162+
else
163+
length = newArray2.length + 1;
164+
// An array of type int storing a new array with the same length as the result array for input value2's digits
165+
int[] array1 = new int[length];
166+
// Copying all digits from value1's original digits array (with leading 0's removed) to this array (array1)
167+
for (int i = 0; i < newArray1.length; i++) {
168+
array1[i] = newArray1[i];
169+
}
170+
// An array of type int storing a new array with the same length as the result array for input value2's digits
171+
int[] array2 = new int[length];
172+
// Copying all digits from value1's original digits array (with leading 0's removed) to this array (array1)
173+
for (int i = 0; i < newArray2.length; i++) {
174+
array2[i] = newArray2[i];
175+
}
176+
// An array storing the resulting array from adding
177+
int[] result = new int[length];
178+
// A variable storing index of result's digits array
179+
int i = 0;
180+
// A temporary variable storing the sum of the addition of each corresponding pair of digits
181+
int s = 0;
182+
// If the values for adding have different signs, throw an UnsupportedOperationException
183+
if (value1.isNegativeNumber() == value2.isNegativeNumber()) {
184+
/* A loop that adds every corresponding pair of digits from the two arrays and stores them in the result array
185+
* Condition: index must be less than or equal to the result array's length */
186+
while (i < result.length) {
187+
s = array1[i] + array2[i] + carry;
188+
if (s >= 10) {
189+
carry = 1;
190+
result[i] = s - 10;
191+
}
192+
else {
193+
carry = 0;
194+
result[i] = s;
195+
}
196+
i++;
197+
}
198+
}
199+
else
200+
throw new UnsupportedOperationException("Invalid inputs");
201+
// A whole number object storing the output of the addition, which will also be returned
202+
ArbitraryWholeNumbers output = new ArbitraryWholeNumbers(false, result);
203+
// If the inputs are negative, the result must also have isNegative set to true
204+
if (value1.isNegativeNumber())
205+
output.isNegative = true;
206+
return output;
207+
}
208+
}

‎Bid.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//David Nguyen - The class Bid represents a bid that a contractor makes for a contract//
2+
public class Bid{
3+
//The contract field represents the contract name for the bid
4+
Contract contract;
5+
//The contractor field represents the contractor's name
6+
Contractor contractor;
7+
//The value field represents the value of the bid
8+
Double value;
9+
10+
//A constructor that creates a bid//
11+
public Bid (Contract contract, Contractor contractor, double value) {
12+
this.contract = contract;
13+
this.contractor = contractor;
14+
this.value = value;
15+
}
16+
17+
//A method that returns the contract for the bid
18+
public Contract contract() {
19+
return contract;
20+
}
21+
22+
//A method that returns the contractor for the bid
23+
public Contractor contractor() {
24+
return this.contractor;
25+
}
26+
27+
//A method that returns the value of the bid//
28+
public double value() {
29+
return this.value;
30+
}
31+
}

‎ComplexNumber.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* A class that represents Complex Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public class ComplexNumber implements ComplexNumberInterface{
7+
8+
// A field representing the real part
9+
private ArbitraryFloatingPointNumbers real;
10+
// A field representing the imaginary part
11+
private ArbitraryFloatingPointNumbers imaginary;
12+
13+
/**
14+
* Creates a Complex Number.
15+
* Assigns the class's fields the values that the constructor got when a ComplexNumber object is created.
16+
* @param real An ArbitraryFloatingPointNumbers that represents a real part
17+
* @param imaginary An ArbitraryFloatingPointNumbers that represents an imaginary part
18+
*/
19+
public ComplexNumber (ArbitraryFloatingPointNumbers real, ArbitraryFloatingPointNumbers imaginary) {
20+
this.real = real;
21+
this.imaginary = imaginary;
22+
}
23+
24+
/**
25+
* A method that retrieves the real part of the complex number.
26+
* @return A floating point number that represents the real part of a complex number
27+
*/
28+
public ArbitraryFloatingPointNumbers getRealPart() {
29+
return real;
30+
}
31+
32+
/**
33+
* A method that retrieves the imaginary part of the complex number.
34+
* @return ArbitraryFloatingPointNumbers A floating point number that represents the imaginary part of a complex number
35+
*/
36+
public ArbitraryFloatingPointNumbers getImaginaryPart() {
37+
return imaginary;
38+
}
39+
40+
/**
41+
* A method that retrieves the imaginary part of the complex number.
42+
* @param number Any ComplexNumber object that is given as input
43+
* @return A Complex Number that is the result of the addition between this ComplexNumber and the input number
44+
*/
45+
public ComplexNumber add(ComplexNumberInterface number) {
46+
ArbitraryFloatingPointNumbers newReal = this.getRealPart().add(this.getRealPart(), number.getRealPart());
47+
ArbitraryFloatingPointNumbers newImaginary = this.getImaginaryPart().add(this.getImaginaryPart(), number.getImaginaryPart());
48+
ComplexNumber result = new ComplexNumber (newReal, newImaginary);
49+
return result;
50+
}
51+
52+
/**
53+
* A method that compares any two complex numbers.
54+
* @param value1 Any ComplexNumber object that is given as input
55+
* @param value2 Any ComplexNumber object that is given as input
56+
* @return A boolean (true or false) depending on equality of these two numbers
57+
*/
58+
public boolean equals(ComplexNumber value1, ComplexNumber value2) {
59+
return (value1.getRealPart().equals(value2.getRealPart())) && (value1.getImaginaryPart().equals(getImaginaryPart()));
60+
}
61+
62+
/**
63+
* A method that returns the string representation of this complex number.
64+
* @return A String that is the proper string representation of the complex number
65+
*/
66+
public String toString() {
67+
String output = new String();
68+
if (!getImaginaryPart().isNegativeNumber()) {
69+
output = (getRealPart() + " + " + getImaginaryPart() + "i");
70+
}
71+
else
72+
output = (getRealPart() + " " + getImaginaryPart() + "i");
73+
return output;
74+
}
75+
}

‎ComplexNumberInterface.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* An interface that represents Complex Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public interface ComplexNumberInterface {
7+
8+
/**
9+
* An abstract method that retrieves the real part of the complex number.
10+
* @return A floating point number that represents the real part of the complex number
11+
*/
12+
ArbitraryFloatingPointNumbers getRealPart();
13+
14+
/**
15+
* An abstract method that retrieves the imaginary part of the complex number
16+
* @return A floating point number that represents the imaginary part of the complex number
17+
*/
18+
ArbitraryFloatingPointNumbers getImaginaryPart();
19+
}

‎Contract.java

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
//David Nguyen - A class that represents a contract
2+
public class Contract {
3+
//The id field represents the ID of the contract
4+
String contractID;
5+
//The minValue field represents the minimum value of the contract
6+
double minValue;
7+
//The maxValue field represents the maximum value of the contract
8+
double maxValue;
9+
//The bonus field represents the per-day bonus associated with the contract
10+
double bonus;
11+
//The penalty field represents the per-day penalty associated with the contract
12+
double penalty;
13+
//The deadline field represents the deadline for the contract
14+
Date deadline;
15+
//The bidAccept field stores whether the contract is still accepting bids or not
16+
boolean bidAccept;
17+
//The bestBid field stores the best bid so far for the contract
18+
Bid bestBid;
19+
//The complete field stores whether the contract is completed or not
20+
boolean complete;
21+
//The completedDay stores the day on which the contract is completed
22+
Date completedDate;
23+
24+
//A constructor that creates a Contract//
25+
public Contract (String contractID, double minValue, double maxValue, double bonus, double penalty, Date deadline) {
26+
this.contractID = contractID;
27+
this.minValue = minValue;
28+
this.maxValue = maxValue;
29+
this.bonus = bonus;
30+
this.penalty = penalty;
31+
this.deadline = deadline;
32+
this.bidAccept = true;
33+
this.bestBid = null;
34+
this.complete = false;
35+
this.completedDate = null;
36+
}
37+
38+
//A method that gets the ID of the contract
39+
public String getID() {
40+
return this.contractID;
41+
}
42+
43+
//A method that gets the minimum value of the contract
44+
public double getMinValue() {
45+
return this.minValue;
46+
}
47+
48+
//A method that sets the minimum value for the contract
49+
public void setMinValue (double value) {
50+
this.minValue = value;
51+
}
52+
53+
//A method that gets the maximum value of the contract
54+
public double getMaxValue() {
55+
return this.maxValue;
56+
}
57+
58+
//A method that sets the maximum value for the contract
59+
public void setMaxValue(double value) {
60+
this.maxValue = value;
61+
}
62+
63+
//A method that gest the per-day bonus associated with the contract
64+
public double getBonus() {
65+
return this.bonus;
66+
}
67+
68+
//A method that sets the per-day bonus
69+
public void setBonus(double bonus) {
70+
this.bonus = bonus;
71+
}
72+
73+
//A method that gets the per-day penalty
74+
public double getPenalty() {
75+
return this.penalty;
76+
}
77+
78+
//A method that sets the per-day penalty
79+
public void setPenalty (double penalty) {
80+
this.penalty = penalty;
81+
}
82+
83+
//A method that gets the deadline for the contract
84+
public Date getDeadline() {
85+
return this.deadline;
86+
}
87+
88+
//A method that sets the deadline for the contract
89+
public void setDeadline(Date deadline) {
90+
this.deadline = deadline;
91+
}
92+
93+
//A method that returns true if a contractor may submit a bid for the contract
94+
public boolean isAcceptingBids() {
95+
return this.bidAccept;
96+
}
97+
98+
//A method that returns the best bid so far for the contract. It returns null if there've been no acceptable bids
99+
public Bid getBestBid() {
100+
if (bidAccept == true)
101+
return this.bestBid;
102+
else
103+
return null;
104+
}
105+
106+
/*A method that returns true if the bid is accepted and becomes the current best bid. However, it returns false
107+
if the bid is not accepted*/
108+
public boolean makeBid (Bid bid) {
109+
Bid bestBidSoFar = getBestBid();
110+
if (bidAccept == false){
111+
return false;
112+
}
113+
else
114+
if (this.minValue <= bid.value && bid.value <= this.maxValue) {
115+
if (bestBidSoFar == null) {
116+
this.bestBid = bestBidSoFar;
117+
return true;
118+
}
119+
else {
120+
if (bid != bestBidSoFar) {
121+
this.bestBid = bestBidSoFar;
122+
return true;
123+
}
124+
}
125+
}
126+
return false;
127+
}
128+
129+
//A method that indicates that the contract is no longer accepting bid
130+
public void awardContract () {
131+
this.bidAccept = false;
132+
}
133+
134+
//A method that returns true if the contract has been completed, or false if not
135+
public boolean isComplete () {
136+
return complete;
137+
}
138+
139+
//A method that returns the date on which the contract was completed, returns null if the contract is not completed
140+
public Date completeDate () {
141+
if (this.complete = true) {
142+
return this.completedDate;
143+
}
144+
else {
145+
return null;
146+
}
147+
}
148+
149+
/*A method that sets the contract to completed, sets the completed date for the contract,
150+
and pay the contractor of the best bid the required amount, which is the sum of the best bid & penalty or bonus*/
151+
public void setComplete (Date completedDate) {
152+
this.completedDate = completedDate;
153+
this.complete = true;
154+
//A variable that stores the amount to be paid to the contractor//
155+
double amountPay = getBestBid().value;
156+
int daysLateOrBeforeDeadline = Date.difference(getDeadline(), completedDate);
157+
//An if-statement that determines the amount to be paid to the contractor based on bonus & bid & penalty
158+
if (daysLateOrBeforeDeadline > 0) {
159+
double penalty = getPenalty() * daysLateOrBeforeDeadline;
160+
amountPay = amountPay + penalty;
161+
}
162+
if (daysLateOrBeforeDeadline < 0) {
163+
double bonus = getBonus() * daysLateOrBeforeDeadline;
164+
amountPay = amountPay - bonus;
165+
}
166+
}
167+
}
168+

‎Contractor.java

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//David Nguyen - A class representing a contractor, including their name, address, contact person, and balance//
2+
public class Contractor {
3+
4+
//A field representing the contractor's name//
5+
private String name;
6+
//A field representing the contractor's address
7+
private String address;
8+
//A field representing the contractors' contact person
9+
private String contact;
10+
//A field representing the balance of the contractor
11+
private double balance;
12+
//A field representing the amount paid to the contractor
13+
private double amount;
14+
15+
//A constructor that creates a contractor//
16+
public Contractor (String name, String address, String contact) {
17+
this.name = name;
18+
this.address = address;
19+
this.contact = contact;
20+
}
21+
22+
//A method that returns the name of the contractor//
23+
public String getName () {
24+
return this.name;
25+
}
26+
//A method that sets the name of the contractor//
27+
//The variable name represents the desired name that will be set to the contractor//
28+
public void setName (String name) {
29+
this.name = name;
30+
}
31+
32+
//A method that returns the address of the contractor
33+
public String getAddress () {
34+
return this.address;
35+
}
36+
37+
//A method that sets the address of the contractor//
38+
//The variable address represents the desired address that will be set to the contractor//
39+
public void setAddress (String address) {
40+
this.address = address;
41+
}
42+
43+
//A method that returns the contact person of the contractor//
44+
public String getContact () {
45+
return this.contact;
46+
}
47+
48+
//A method that sets the name of the contact person of the contractor
49+
//The variable name represents the name of the contact person of the contractor
50+
public void setContact (String contact) {
51+
this.contact = contact;
52+
}
53+
54+
//A method that returns the amount that has been paid to the contractor
55+
public double getAmountPaid () {
56+
return this.amount;
57+
}
58+
59+
//A method that pays the contractor the specified amount
60+
//The variable amount represents the specified amount paid to the contractor
61+
public void pay (double amount) {
62+
this.amount = this.amount + amount;
63+
this.balance = this.balance + this.amount;
64+
}
65+
66+
//A method that override the inherited toString method to represent the contractor name, address, and contact
67+
public String toString() {
68+
return getName() + ", " + getAddress() + ", " + getContact();
69+
}
70+
71+
/* A method that override the inherited equals method to determine if the two contractor instances are equal
72+
(if their names are equal)*/
73+
public boolean equals(Object o) {
74+
if (o instanceof Contractor) {
75+
Contractor c = (Contractor)o;
76+
if (this.getName() == c.getName())
77+
return true;
78+
else
79+
return false;
80+
}
81+
return false;
82+
}
83+
}

‎Date.java

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
//David Nguyen - Date class: A class that represents a date (With Extra Credit)//
2+
public class Date {
3+
4+
//A field that represents the day of the date//
5+
private int day;
6+
//A field that represents the month of the date//
7+
private Month month;
8+
//A field that represents the year of the date//
9+
private int year;
10+
//A field that represents the current date//
11+
private String date;
12+
//A variable storing whether the date is being displayed in a US format
13+
boolean isInUSFormat;
14+
15+
//Extra-Credit Attempt: An enum type that represents the months in a year from January to December
16+
public enum Month {
17+
//Declaring the maximum number of days for each month
18+
JAN(31),
19+
FEB(28),
20+
MAR(31),
21+
APR(30),
22+
MAY(31),
23+
JUN(30),
24+
JUL(31),
25+
AUG(31),
26+
SEP(30),
27+
OCT(31),
28+
NOV(30),
29+
DEC(31);
30+
31+
//A variable that stores the maximum number of days of each month
32+
private final int numDays;
33+
34+
//A constructor that sets the maximum number of days of each month
35+
Month(int numDays) {
36+
this.numDays = numDays;
37+
}
38+
39+
//A method that returns the maximum number of days of each month
40+
public int getNumDayOfMonth(Month month) {
41+
return this.numDays;
42+
}
43+
44+
//A method returning the number of days between December 31st of previous year and the 1st of the selected month
45+
public static int dayOfYear(Month month) {
46+
//A variable that stores the number of days between December 31st of previous year and the 1st of this month.
47+
int numDaysFromDec31;
48+
//Calculating the number of days from December 31st of previous year and the 1st of this month
49+
if (month == JAN)
50+
numDaysFromDec31 = 1;
51+
else if (month == FEB)
52+
numDaysFromDec31 = 1 + 31;
53+
else if (month == MAR)
54+
numDaysFromDec31 = 1 + 31 + 28;
55+
else if (month == APR)
56+
numDaysFromDec31 = 1 + 31 + 28 + 31;
57+
else if (month == MAY)
58+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30;
59+
else if (month == JUN)
60+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30 + 31;
61+
else if (month == JUL)
62+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30 + 31 + 30;
63+
else if (month == AUG)
64+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30 + 31 + 30 + 31;
65+
else if (month == SEP)
66+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31;
67+
else if (month == OCT)
68+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30;
69+
else if (month == NOV)
70+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;
71+
else
72+
numDaysFromDec31 = 1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;
73+
return numDaysFromDec31;
74+
}
75+
}
76+
77+
//A constructor that creates a Date object with the int inputs being the day, month, and year of the date//
78+
public Date (int day, Month month, int year) {
79+
this.day = day;
80+
this.month = month;
81+
this.year = year;
82+
this.date = this.month + "/" + this.day + "/" + this.year;
83+
this.isInUSFormat = false;
84+
}
85+
86+
//A method that returns the number of days between this Date and January 1 of the same year//
87+
public int daysFromJan1() {
88+
//A variable that stores the number of days from Jan 1
89+
int numberOfDays;
90+
//A statement that adds the number of days that have passed from Jan 1 to the current date to calculate days from Jan 1//
91+
numberOfDays = Month.dayOfYear(this.month) + this.day;
92+
return numberOfDays;
93+
}
94+
95+
/*A method that returns the day of the date. If the day falls outside the range 0-31,
96+
the day is invalid and program returns 00*/
97+
public int getDay () {
98+
if (1 < this.day && this.day < 31)
99+
return this.day;
100+
else
101+
return 0;
102+
}
103+
104+
/*A method that returns the month of the date*/
105+
public Month getMonth() {
106+
return this.month;
107+
}
108+
109+
//A method that returns the year of the date//
110+
public int getYear () {
111+
return this.year;
112+
}
113+
114+
//A method that sets the date to the US date formatting. If the input is true, change to US Formatting and vice versa
115+
public void setUSFormat(boolean useUSFormat) {
116+
if (useUSFormat == false) {
117+
this.date = this.date;
118+
}
119+
else {
120+
this.date = this.month + "/" + this.day + "/" + this.year;
121+
}
122+
}
123+
124+
//A method that checks whether the date is being displayed in a US format//
125+
public boolean isUSFormat() {
126+
/*An if-statement that returns true & set the value of the variable isInUSFormat to true if the date is displayed
127+
in the US Format and vice versa*/
128+
if (this.date == this.month + "/" + this.day + "/" + this.year) {
129+
isInUSFormat = true;
130+
}
131+
else {
132+
isInUSFormat = false;
133+
}
134+
return isInUSFormat;
135+
}
136+
137+
//A method that takes 2 dates and returns the difference in days between the two//
138+
public static int difference(Date date1, Date date2) {
139+
//A variable that stores the difference in terms of year between the two dates//
140+
int yearDifference = date1.year - date2.year;
141+
//A variable that stores the difference in days between the two given dates//
142+
int totalDays = 0;
143+
//A variable that stores the difference in terms of days between the two dates in the same year//
144+
int dayDifference = date1.daysFromJan1() - date2.daysFromJan1();
145+
/*An if-statement that calculates the difference in terms of days between the two days*/
146+
if (yearDifference < 0)
147+
totalDays = (yearDifference * 365) + dayDifference;
148+
else
149+
totalDays = (yearDifference * 365) + dayDifference;
150+
return totalDays;
151+
}
152+
153+
//A method that override the inherited toString() method to display the date based on the desired format//
154+
public String toString() {
155+
if (isInUSFormat == true) {
156+
return (this.getMonth() + " " + this.getDay() + ", " + this.getYear());
157+
}
158+
else {
159+
return (this.getDay() + " " + this.getMonth() + ", " + this.getYear());
160+
}
161+
}
162+
163+
/*A method that override the inherited equals() method to compare the two date instances.
164+
The two dates are equal if they have the same day, month, year values, and vice versa*/
165+
public boolean equals(Object o) {
166+
if (o instanceof Date) {
167+
Date d = (Date)o;
168+
if (this.getDay() == d.getDay() && this.getMonth() == d.getMonth() && this.getYear() == d.getYear())
169+
return true;
170+
else
171+
return false;
172+
}
173+
return false;
174+
}
175+
}

‎GaussianInteger.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* A class that represents Gaussian Integers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public class GaussianInteger implements GaussianIntegerInterface {
7+
8+
//A field representing the real part
9+
private ArbitraryWholeNumbers real;
10+
//A field representing the imaginary part
11+
private ArbitraryWholeNumbers imaginary;
12+
13+
/**
14+
* Creates a Gaussian Integer.
15+
* Assigns the class's fields the values that the constructor got when a GaussianInteger object is created.
16+
* @param real An ArbitraryWholeNumbers that represents a real part
17+
* @param imaginary An ArbitraryWholeNumbers that represents an imaginary part
18+
*/
19+
public GaussianInteger(ArbitraryWholeNumbers real, ArbitraryWholeNumbers imaginary) {
20+
this.real = real;
21+
this.imaginary = imaginary;
22+
}
23+
24+
/**
25+
* A method that retrieves the real part of a gaussian integer.
26+
* @return A whole number that represents the real part of a gaussian integer
27+
*/
28+
public ArbitraryWholeNumbers getRealPart() {
29+
return real;
30+
}
31+
32+
/**
33+
* A method that retrieves the imaginary part of a gaussian integer.
34+
* @return A whole number that represents the imagainary part of a gaussian integer
35+
*/
36+
public ArbitraryWholeNumbers getImaginaryPart() {
37+
return imaginary;
38+
}
39+
40+
/**
41+
* A method that retrieves the imaginary part of the complex number.
42+
* @param number Any GaussianInteger object that is given as input
43+
* @return A Gaussian Integer that is the result of the addition between this Gaussian Integer and the input number
44+
*/
45+
public GaussianInteger add(GaussianIntegerInterface number) {
46+
ArbitraryWholeNumbers newReal = this.getRealPart().add(this.getRealPart(), number.getRealPart());
47+
ArbitraryWholeNumbers newImaginary = this.getImaginaryPart().add(this.getImaginaryPart(), number.getImaginaryPart());
48+
GaussianInteger result = new GaussianInteger (newReal, newImaginary);
49+
return result;
50+
}
51+
52+
/**
53+
* A method that compares any two gaussian integers.
54+
* @param value1 Any GaussianInteger object that is given as input
55+
* @param value2 Any GaussianInteger object that is given as input
56+
* @return A boolean (true or false) depending on equality of these two numbers
57+
*/
58+
public boolean equals (GaussianIntegerInterface value1, GaussianIntegerInterface value2) {
59+
return (value1.getRealPart().equals(value2.getRealPart())) && (value1.getImaginaryPart().equals(getImaginaryPart()));
60+
}
61+
62+
/**
63+
* A method that returns the string representation of this gaussian integer.
64+
* @return A String that is the proper string representation of the gaussian integer
65+
*/
66+
public String toString() {
67+
String output = new String();
68+
if (!getImaginaryPart().isNegativeNumber()) {
69+
output = (getRealPart() + " + " + getImaginaryPart() + "i");
70+
}
71+
else
72+
output = (getRealPart() + " " + getImaginaryPart() + "i");
73+
return output;
74+
}
75+
}

‎GaussianIntegerInterface.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* An interface that represents Gaussian Integers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public interface GaussianIntegerInterface extends ComplexNumberInterface {
7+
8+
/**
9+
* An abstract method that retrieves the real part of the gaussian integers.
10+
* @return A whole number that represents the real part of the gaussian integers
11+
*/
12+
ArbitraryWholeNumbers getRealPart();
13+
14+
/**
15+
* An abstract method that retrieves the imaginary part of the gaussian integers.
16+
* @return A whole number that represents the imaginary part of the gaussian integers
17+
*/
18+
ArbitraryWholeNumbers getImaginaryPart();
19+
}

‎HW3Tester.java

Lines changed: 1577 additions & 0 deletions
Large diffs are not rendered by default.

‎IntegerNumber.java

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* A class that represents Integer Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public class IntegerNumber implements IntegerNumberInterface{
7+
8+
//A field representing the real part
9+
private ArbitraryWholeNumbers number;
10+
11+
/**
12+
* Creates a Integer Number.
13+
* Assigns the class's fields the values that the constructor got when a IntegerNumber object is created.
14+
* @param number An ArbitraryWholeNumbers that represents the input integer
15+
*/
16+
public IntegerNumber(ArbitraryWholeNumbers number) {
17+
this.number = number;
18+
}
19+
20+
/**
21+
* A method that retrieves the number part of the integer number.
22+
* @return A whole number that represents the number part of an integer number
23+
*/
24+
public ArbitraryWholeNumbers getNumber() {
25+
return number;
26+
}
27+
28+
/**
29+
* Overriding the getNumerator() method inherited from class RationalNumber.
30+
* Retrieves the numerator of the integer number - which should always be the number itself to correctly represent the
31+
* integer number. The denominator in this case must also be 1.
32+
* @return A whole number that represents the number part of an integer number
33+
*/
34+
public ArbitraryWholeNumbers getNumerator() {
35+
return number;
36+
}
37+
38+
/**
39+
* Overriding the getDenominator() method inherited from class RationalNumber
40+
* Retrieves the denominator of the integer number - which should always be the number of 1 to correctly represent the
41+
* integer number
42+
* @return A whole number that represents the number part of an integer number
43+
*/
44+
public ArbitraryWholeNumbers getDenominator() {
45+
return (new ArbitraryWholeNumbers (false, new int[] {1}));
46+
}
47+
48+
/**
49+
* Overriding the getRealPart() method inherited from class GaussianInteger
50+
* A method that retrieves the real part of the integer number - which should be the integer number itself
51+
* @return A whole number that represents the real part of an integer number
52+
*/
53+
public ArbitraryWholeNumbers getRealPart() {
54+
return number;
55+
}
56+
57+
/**
58+
* Overriding the getImaginaryPart() method inherited from class GaussianInteger.
59+
* A method that retrieves the imaginary part of the Gaussian Integer - which should be 0 because an integer number.
60+
* cannot have any imaginary parts
61+
* @return A whole number that represents the imaginary part of an integer number
62+
*/
63+
public ArbitraryWholeNumbers getImaginaryPart() {
64+
return (new ArbitraryWholeNumbers (false, new int[] {0}));
65+
}
66+
67+
/**
68+
* A method that retrieves the imaginary part of the integer number.
69+
* @param number1 Any IntegerNumber object that is given as input
70+
* @param number2 Any IntegerNumber object that is given as input
71+
* @return An Integer Number that is the result of the addition between this Gaussian Integer and the input number
72+
*/
73+
public IntegerNumber add(IntegerNumberInterface number1, IntegerNumberInterface number2) {
74+
ArbitraryWholeNumbers result = number1.getNumber().add(number1.getNumber(), number2.getNumber());
75+
IntegerNumber output = new IntegerNumber(result);
76+
return output;
77+
}
78+
79+
/**
80+
* A method that compares the two integer numbers.
81+
* @param value1 Any IntegerNumber object that is given as input
82+
* @param value2 Any IntegerNumber object that is given as input
83+
* @return An Integer Number that is the result of the addition between this Integer Number and the input number
84+
*/
85+
public boolean equals(IntegerNumberInterface value1, IntegerNumberInterface value2) {
86+
return (value1.getNumber().equals(value2.getNumber()));
87+
}
88+
89+
/**
90+
* A method that returns the string representation of this integer number.
91+
* @return A string that is the string represenation of this integer number
92+
*/
93+
public String toString() {
94+
return getNumber().toString();
95+
}
96+
}

‎IntegerNumberInterface.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* An interface that represents Integer Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public interface IntegerNumberInterface extends GaussianIntegerInterface, RationalNumberInterface {
7+
8+
/**
9+
* An abstract method that retrieves the number part of the integer number.
10+
* @return A whole number that represents the number part of the integer number
11+
*/
12+
ArbitraryWholeNumbers getNumber();
13+
14+
}

‎NaturalNumber.java

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* A class that represents Natural Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public class NaturalNumber implements NaturalNumberInterface{
7+
8+
//A field representing the real part
9+
private ArbitraryWholeNumbers number;
10+
11+
/**
12+
* Creates a Natural Number. A natural number is a whole number that is not negative
13+
* Assigns the class's fields the values that the constructor got when a NaturalNumber object is created.
14+
* @param number An ArbitraryWholeNumbers that represents the input integer
15+
*/
16+
public NaturalNumber(ArbitraryWholeNumbers number) {
17+
if (!number.isNegativeNumber())
18+
this.number = number;
19+
else {
20+
throw new UnsupportedOperationException("Please enter a positive natural number!");
21+
}
22+
}
23+
24+
/**
25+
* A method that retrieves the number of the natural number.
26+
* @return A whole number that represents the natural number
27+
*/
28+
public ArbitraryWholeNumbers getNumber() {
29+
return number;
30+
}
31+
32+
/**
33+
* Overriding the getRealPart() method inherited from class GaussianInteger.
34+
* A method that retrieves the imaginary part of the Gaussian Integer - which should be 0 because an integer number
35+
* cannot have any imaginary parts.
36+
* @return A whole number that represents the imaginary part of an integer number
37+
*/
38+
public ArbitraryWholeNumbers getImaginaryPart() {
39+
return (new ArbitraryWholeNumbers (false, new int[] {0}));
40+
}
41+
42+
/**
43+
* Overriding the getRealPart() method inherited from class GaussianInteger.
44+
* A method that retrieves the real part of a natural number - which that natural number itself
45+
* @return A whole number that represents a natural number
46+
*/
47+
public ArbitraryWholeNumbers getRealPart() {
48+
return number;
49+
}
50+
51+
/**
52+
* Overriding the getNumerator() method inherited from class RationalNumber.
53+
* A method that retrieves the numerator of a natural number - which is the number itself if the
54+
* denominator is 1, and the denominator must also be 1 in this case
55+
* @return A whole number that represents a natural number
56+
*/
57+
public ArbitraryWholeNumbers getNumerator() {
58+
return number;
59+
}
60+
61+
/**
62+
* Overriding the getDenominator() method inherited from class RationalNumber.
63+
* A method that retrieves the denominator of a natural number - which should be 1 and always 1 for a natural number
64+
* to be correctly represented
65+
* @return A whole number that represents a natural number
66+
*/
67+
public ArbitraryWholeNumbers getDenominator() {
68+
return (new ArbitraryWholeNumbers (false, new int[] {1}));
69+
}
70+
71+
/**
72+
* A method that computes the sum of this Natural Number and any input Natural Number.
73+
* @param number Any NaturalNumber object that is given as input
74+
* @return A NaturalNumber object that is the sum of these two natural numbers
75+
*/
76+
public NaturalNumber add(NaturalNumberInterface number) {
77+
ArbitraryWholeNumbers sum = this.getNumber().add(number.getNumber(), this.getNumber());
78+
NaturalNumber result = new NaturalNumber (sum);
79+
return result;
80+
}
81+
82+
/**
83+
* A method that compares this Natural Number and any given input Natural Number.
84+
* @param value Any given natural number
85+
* @return A boolean (true or false) depending on the equality of these two numbers
86+
*/
87+
public boolean equals(NaturalNumber value) {
88+
return (this.getNumber().equals(value.getNumber()));
89+
}
90+
91+
/**
92+
* A method that creates a string representation of the give natural number
93+
* @return A String that is the string representation of the given natural number
94+
*/
95+
public String toString() {
96+
return this.getNumber().toString();
97+
}
98+
}

‎NaturalNumberInterface.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* An interface that represents Natural Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public interface NaturalNumberInterface extends IntegerNumberInterface {
7+
8+
}

‎RationalNumber.java

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* A class that represents Rational Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public class RationalNumber implements RationalNumberInterface{
7+
8+
//A field representing the real part
9+
private ArbitraryWholeNumbers numerator;
10+
//A field representing the imaginary part
11+
private ArbitraryWholeNumbers denominator;
12+
13+
/**
14+
* Creates a Rational Number.
15+
* Assigns the class's fields the values that the constructor got when a RationalNumber object is created.
16+
* @param numerator An ArbitraryWholeNumbers that represents the numerator
17+
* @param denominator An ArbitraryWholeNumbers that represents the denominator
18+
*/
19+
public RationalNumber (ArbitraryWholeNumbers numerator, ArbitraryWholeNumbers denominator) {
20+
this.numerator = numerator;
21+
this.denominator = denominator;
22+
}
23+
24+
/**
25+
* A method that retrieves the numerator of the rational number.
26+
* @return A whole number that represents the numerator of the rational number
27+
*/
28+
public ArbitraryWholeNumbers getNumerator() {
29+
return numerator;
30+
}
31+
32+
/**
33+
* A method that retrieves the denominator of the rational number.
34+
* @return A whole number that represents the denominator of the rational number
35+
*/
36+
public ArbitraryWholeNumbers getDenominator() {
37+
return denominator;
38+
}
39+
40+
/**
41+
* Overriding the getNumber() method that is inherited from class RealNumber.
42+
* Retrieving the number of the rational number - Retrieving the real part of the rational number, which is the
43+
* number itself, by returning either null if the denominator is not 1, as the rational cannot be represented in one
44+
* whole number, or returns the numerator if the denominator is 1
45+
* @return A whole number that represents the denominator of the rational number
46+
*/
47+
public ArbitraryWholeNumbers getNumber() {
48+
return numerator;
49+
}
50+
51+
/**
52+
* Overriding the getRealPart() method that is inherited from class RealNumber.
53+
* Retrieving the real part of the rational number, which is the number itself, by returning either null if the
54+
* denominator is not 1, as the rational cannot be represented in one whole number, or returns the numerator if
55+
* the denominator is 1
56+
* @return A whole number that represents the rational number
57+
*/
58+
public ArbitraryWholeNumbers getRealPart() {
59+
return numerator;
60+
}
61+
62+
/**
63+
* Overriding the getImaginaryPart() method that is inherited from class RealNumber.
64+
* Retrieving the imaginary part of the rational number, which is assumed to be null because a rational number cannot
65+
* be imaginary
66+
* @return null
67+
*/
68+
public ArbitraryWholeNumbers getImaginaryPart() {
69+
return (new ArbitraryWholeNumbers (false, new int[] {0}));
70+
}
71+
72+
/**
73+
* A method that computes the sum of this Rational Number and any input Rational Number.
74+
* @param number Any RationalNumber object that is given as input
75+
* @return A RationalNumber object that is the sum of these two natural numbers
76+
*/
77+
public RationalNumber add(RationalNumberInterface number) {
78+
if (this.getDenominator().equals(number.getDenominator())) {
79+
ArbitraryWholeNumbers newNumerator = this.getNumerator().add(this.getNumerator(), number.getNumerator());
80+
return (new RationalNumber (newNumerator, number.getDenominator()));
81+
}
82+
else
83+
throw new UnsupportedOperationException("Invalid inputs");
84+
}
85+
86+
/**
87+
* A method that compares this Rational Number and any given input Rational Number
88+
* @param value1 Any given RationalNumber number
89+
* @param value2 Any given RationalNumber number
90+
* @return A boolean (true or false) depending on the equality of these two numbers
91+
*/
92+
public boolean equals (RationalNumber value1, RationalNumber value2) {
93+
return (value1.getNumerator().equals(value2.getNumerator())) && (value1.getDenominator().equals(getDenominator()));
94+
}
95+
96+
/**
97+
* A method that creates a string representation of this Rational Number
98+
* @return A String that is the string representation of this Rational Number
99+
*/
100+
public String toString () {
101+
return (getNumerator() + " / " + getDenominator());
102+
}
103+
}

‎RationalNumberInterface.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* An interface that represents Rational Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public interface RationalNumberInterface extends RealNumberInterface {
7+
8+
/**
9+
* An abstract method that retrieves the numerator part of the rational numbers.
10+
* @return A whole number that represents the numerator part of the rational numbers
11+
*/
12+
ArbitraryWholeNumbers getNumerator();
13+
14+
/**
15+
* An abstract method that retrieves the denominator part of the rational numbers.
16+
* @return A whole number that represents the denominator part of the grational numbers
17+
*/
18+
ArbitraryWholeNumbers getDenominator();
19+
20+
}

‎RealNumber.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* A class that represents Real Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public class RealNumber implements RealNumberInterface {
7+
8+
//A field representing a real, floating-point number
9+
private ArbitraryFloatingPointNumbers number;
10+
11+
/**
12+
* Creates a Real Number.
13+
* Assigns the class's fields the values that the constructor got when a RealNumber object is created.
14+
* @param number An ArbitraryFloatingPointNumbers that represents the number
15+
*/
16+
public RealNumber (ArbitraryFloatingPointNumbers number) {
17+
this.number = number;
18+
}
19+
20+
/**
21+
* A method that retrieves the number of the real number.
22+
* @return A floating point number that represents the number of the real number.
23+
*/
24+
public ArbitraryFloatingPointNumbers getNumber() {
25+
return number;
26+
}
27+
28+
/**
29+
* Overriding the getRealPart() method inherited from class ComplexNumber.
30+
* A method that retrieves the real part of the real number - which is the number itself
31+
* @return A floating point number that represents the number of the real number
32+
*/
33+
public ArbitraryFloatingPointNumbers getRealPart() {
34+
return number;
35+
}
36+
37+
/**
38+
* Overriding the getImaginaryPart() method inherited from class ComplexNumber
39+
* A method that retrieves the imaginary part of the real number - which should be 0 because a real number cannot
40+
* have any imaginary parts
41+
* @return A floating point number that represents the number of the real number
42+
*/
43+
public ArbitraryFloatingPointNumbers getImaginaryPart() {
44+
return (new ArbitraryWholeNumbers (false, new int[] {0}));
45+
}
46+
47+
/**
48+
* A method that computes the sum of this Real Number and any input Real Number
49+
* @param number Any RealNumber object that is given as input
50+
* @return A RealNumber object that is the sum of the two real numbers
51+
*/
52+
public RealNumber add(RealNumberInterface number) {
53+
ArbitraryFloatingPointNumbers sum = this.getNumber().add(this.getNumber(), number.getNumber());
54+
RealNumber result = new RealNumber (sum);
55+
return result;
56+
}
57+
58+
/**
59+
* A method that compares this RealNumber and any given input RealNumber
60+
* @param value1 Any given RealNumber number
61+
* @param value2 Any given RealNumber number
62+
* @return A boolean (true or false) depending on the equality of these two numbers
63+
*/
64+
public boolean equals (RealNumber value1, RealNumber value2) {
65+
return (value1.getNumber().equals(value2.getNumber()));
66+
}
67+
68+
/**
69+
* A method that creates a string representation of this Real Number
70+
* @return A String that is the string representation of this Real Number
71+
*/
72+
public String toString() {
73+
return number.toString();
74+
}
75+
}

‎RealNumberInterface.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* An interface that represents Real Numbers
3+
* @author David Nguyen
4+
* @since 11/14/2022
5+
*/
6+
public interface RealNumberInterface extends ComplexNumberInterface {
7+
8+
/**
9+
* An abstract method that retrieves the number part of the integer number.
10+
* @return A whole number that represents the number part of the integer number
11+
*/
12+
ArbitraryFloatingPointNumbers getNumber();
13+
14+
}

0 commit comments

Comments
 (0)
Please sign in to comment.