首页 > > 详细

代写software留学生作业、代做Python,c++编程设计作业、代写Java实验作业帮做C/C++编程|代做留学生Processing

Homework #2
In this homework we will also go through multiple small tasks which we will use during the next class to talk about design patterns, software, etc. The solutions for this homework should be in the following form. All answers should be in a packages edu.nyu.compfin19.homework2.Question1, edu.nyu.compfin19.homework2.Question2, … . Each package should be self-contained and not reference any classes from other packages. All classes needs to be unit tested.

1.You should write a class called Exchange that implement a method public double price() which returns a random number. You should write a class called Trader that accepts a DoubleSupplier on the constructor and have one method public void run(). The run method prints the first 10 numbers provided by the supplier. Write a main class named Question one that creates an Exchange and a Trader that accepts the exchange as an input and calls the Trader run method.
2.We want to have ten traders, and they all want to see the same numbers in the same order. Essentially, the output needs to be
Trader 1: 345
Trader 2: 345

Trader 10: 345
Trader 1: 897
….
You will now need to change the Trader constructor, what the run method does and how to use it, and the Exchange.

3.Now repeat question 2 without but now with 7 Traders.

Do we really want to Hardcode the Exchange all the time?

4.Write an Exchange class. The Exchange class now have a method called consumer(DoubleConsumer doubleConsumer) that accepts consumer. Every time that the method is called, the consumer given is added to a set. The Exchange have another method called removeConsumer(DoubleConsumer doubleConsumer) that whenever called remove the consumer from the set. (Keep in mind edge cases like null input and guard from them)
5.Write a class called Trader that now has a method called price(double price). The method prices the price to standard out.
6.Write a class named Questions6 that has a main class that use the classes from Question 4 and 5 to print the ten numbers to the screen as we did if the first question.
7.Write a class named Question7 with a main class that starts ten new Traders and print output similar to question 2 but with the classes we wrote in questions 4 and 5.
8.Write a class named Question7 with a main class that starts ten new Traders and print output similar to question 2 but now Trader number ten prints ONLY the first five numbers.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点文章
程序代写更多图片

联系我们 - QQ: 99515681 微信:codinghelp
© 2014 www.7daixie.com
程序代写网!