Question: Write a program where you will design and implement a class that uses lists to implement a new data type which will be referred to
Write a program where you will design and implement a class that uses lists to implement a new data type which will be referred to as InfInt - integers which can hold extremely large integer values, much larger than c# int's (32 bits) or even c# long's (64 bits). C# ints can contain values between -2,147,483,648 and 2,147,483,647 while c# longs can hold values between - 9,223,372,036,854,775,808 and 9,223,372,036,854,775,807. The new data type which you will create will be able to deal with integer values which can be much larger than c# longs. Your program should implement class InfInt using a list in which each node contains a data value of type int which represents a single decimal digit.
This data value will represent the multiplier of one power of ten in the number being represented. Thus the decimal number: 345 = 3*100 + 4*10 + 1 would be represented by a three node linked list in which one node contains a 5, one node contains a 4 and one node contains a 3. The place or power of ten represented by each node is understood from the order of the nodes.
Use the c# List class to hold your InfInt objects in your driver program you would create the List of InfInt objects with the following code:
var A = new List;
Your program should implement the operations of addition, subtraction, and multiplication for the InfInt data type by creating plus, minus and times methods.
Your task of writing these methods will be made much easier if you have your InfInt class implement the Comparable interface and start by writing compareTo() which can then be used in plus(), minus() and times(). You will also need to learn how to open a txt file and parse the data in c#.
Your program should be capable of reading one infinite integer into an InfInt object named A and reading the other infinite integer into an InfInt object named B and then performing the arithmetic operation and printing the result with a statement similar to: Console.WriteLine($"A + B = {A.plus(B)});
Note that negative numbers are possible either given explicitly or as a calculated result.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
