The purpose of this lab is to gain experience in the design


The purpose of this lab is to gain experience in the design and implementation of a simple Java class.  You will create a class definition and write a simple main method that will test the methods of your class to ensure they work as expected.

The required task is to create a class definition for the concept of a Roman numeral.  When a Roman numeral object is declared, it should hold a representation of the Roman numeral (e.g., MMXV) and provide the following functionality:

  • A constructor that initializes the Roman numeral to the value supplied as the parameter to the constructor in Roman numeral format
  • A constructor that initializes the Roman numeral to the value supplied as the parameter to the constructor in decimal format
  • A method that returns the value of the Roman numeral
  • A method that returns the decimal equivalent of the value of the Roman numeral

Note: a Roman numeral object is only allowed to permanently store the Roman numeral representation of the number (i.e., adding an int member for the decimal equivalent is not allowed).

Your test program must create Roman numeral objects and enable the user to sufficiently test the class methods for correctness.  I/O can be console based - e.g., you may want to prompt the user for a Roman numeral, create a Roman numeral object and then output the numeral in both Roman numeral and decimal format.

The extended task is to add functionality to the class to add Roman numerals.  Note to get any credit for this method this addition must be done using the Roman numeral format of the numbers, not by converting them to decimal values and adding those.  Your test code should be extended to allow the user to exercise the add function as many times as desired.

As a reminder, these are the decimal values of the Roman numeral "digits":

M    1000
D    500
C    100
L    50
X    10
V    5
I    1

Solution Preview :

Prepared by a verified Expert
JAVA Programming: The purpose of this lab is to gain experience in the design
Reference No:- TGS01224182

Now Priced at $35 (50% Discount)

Recommended (90%)

Rated (4.3/5)

A

Anonymous user

2/24/2016 7:18:31 AM

The given assignment is basically to design and implement of a simple Java class. In this, you have to create a class definition and write down a simple main method which will test the methods of your class to make sure they work as estimated. The task requisite is to create a class definition for the concept of the Roman numeral. If a Roman numeral object is declared, it must hold a representation of the Roman numeral and provide the given functionality: 1) A constructor which initializes the Roman numeral to the value supplied as the parameter to the constructor in the format of Roman numeral. 2) A constructor which initializes the Roman numeral to the value supplied as the parameter to the constructor in the decimal format. 3) A method which returns the value of the Roman numeral. 4) A method which returns the decimal equivalent of the value of Roman numeral.