编程辅导 C C++ Java Python MIPS Processing 网络家教 在线辅导

编程家教 远程写代码 Debug 讲解答疑 课后答疑 不是中介,本人直接答疑

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

Objectives: abstract data type (ADT), encapsulation
Integer types are very convenient, but their limited width makes them unsuitable for some applications where precise large values are more important than speed. Develop a class
VeryLargeInteger
that can handle arbitrary long integer numbers (both negative and positive) and the basic arithmetic operations (addition, subtraction, multiplication, division, and remainder).
Hint: The number could be represented as string, the sign could be represented either as boolean
or as part of the string.
Note: Implementations of addition/subtraction through repeated use of a constant increment/decrement will not be accepted. Implementations of multiplication and division that rely on
stepwise addition or subtraction will not be accepted.
/∗∗
VeryLargeInteger (VLI) is a class for arbitrary precision integer computation.
/
public class VeryLargeInteger f
/∗∗
Constructs a new VLI object from a long integer.
@param init initial value
/
VeryLargeInteger(
long init) f /YOUR CODE / g
/∗∗
Constructs a new VLI object from a String.
@param init initial value. Note, the string represents a valid VLI, but can
be prefixed with a sign (either + or -).
/
VeryLargeInteger(String init)
f /YOUR CODE / g
/∗∗
Computes this+other and returns the result in a new object.
@param other the left-hand side operand.
@return a new VLI representing this+other
/
VeryLargeInteger add(VeryLargeInteger other)
f /YOUR CODE / g
/∗∗
Computes this-other and returns the result in a new object.
@param other the left-hand side operand.
@return a new VLI representing this-other
/
VeryLargeInteger sub(VeryLargeInteger other)
f /YOUR CODE / g
/∗∗
Computes thisother and returns the result in a new object.
1
@param other the left-hand side operand.
@return a new VLI representing thisother
/
VeryLargeInteger mul(VeryLargeInteger other)
f /YOUR CODE / g
/∗∗
Computes this/other and returns the result in a new object.
@param other the left-hand side operand.
@return a new VLI representing this/other
/
VeryLargeInteger div(VeryLargeInteger other)
f /YOUR CODE / g
/∗∗
Computes this%other and returns the result in a new object.
@param other the left-hand side operand.
@return a new VLI representing this%other
/
VeryLargeInteger mod(VeryLargeInteger other)
f /YOUR CODE / g
/∗∗
Returns the textual representation of this VLI.
@result a string representing this VLI
/
String toString()
f /YOUR CODE / g
/YOUR CODE /
g
Turn in a zip file named blazerid hw1.zip. The file should contain an exported Eclipse project1
with the following items.
All files needed to compile and run your solution.
Your tests (test driver needs to be a separate file).
A document (or text file) that describes your design decisions, your tests, any difficulties you
had. If you would like to get a graded version on paper, add a note at the top of the report
saying \
paper copy requested". If you received help from somebody else in class, please give
credit to them.
Grading (50 pts max)
(10pts) Lab (September 14).
(10pts) Assignment report.
(10pts) Turned in code compiles without error or warning and code is well documented
(consider using -Xlint:all and/or checkStyle).
(10pts) Quality of test design.
(10pts) Constructors, addition, subtraction, multiplication, and toString work correctly.
(10pts) Division and remainder methods operations correctly.
1If you do not use Eclipse, the turned in file also needs to have a file readme.txt in its top directory that explains
how to compile and test your code.
2  

相关推荐