Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do it in scala and explain every step thanks In a package named execution, implement the following classes: class Valuable Constructor takes one variable as

Do it in scala and explain every step thanks

In a package named "execution", implement the following classes: class Valuable Constructor takes one variable as a parameter named "item" of type Valuable (use var) This class represents someone with a valuable item they are wiling to trade. Each trader can only own 1 item at a time which is stored in the "item" state variable class TradeAgreement Constructor takes 2 objects of type Trader One method named "executeTrade" that take no parameters and returns Unit When this method is called, swap the items belonging to the 2 traders from the constructor (ie. When a TradeAgreement is created, 2 people are agreeing to a trade. When executeTrade is called, they physically trade those items) The agreement can only be executed once. If this method is called more than once for a single agreement, additional trades are not made (ie. The people do not trade back to their original items if this method is called twice)

Testing: In a package named "tests" create a Scala class named "TestTrading" as a test suite that tests all the functionality listed above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Discuss cultural and situational factors that influence hunger.

Answered: 1 week ago

Question

2. Outline the functions of nonverbal communication

Answered: 1 week ago