Project in Java due for next week

Online tutoring services

Need help with this question or any other Java Programming assignment help task? Click on the button below to to hire an expert cheap.

Project in java assistance request. Please review the attached files and take your time to go over it Here is the Good Drive link for the folder. File was too large to attach to the Tutlance.com website. https://drive.google.com/file/d/1QOqgnCxgmn0yGGdu84KoUaCdwIwVWM3u/view?usp=sharing

Get Help With a similar task to - Project in Java due for next week

Login to view and/or buy answers.. or post an answer
Additional Instructions:
Page 1 of 4 String Rendezvous Project 1. Complete the class StringHandoffImpl to fully implement the behavior described in the StringHandoff interface. 2. There are two projects in the zip file: "PROJ_ThreadRendezvous" and "Parallel-Common-PROJ-ThreadRendezvous". Import them both from the zip archive. a. StringHandoff.java and most of the tests are located in "Parallel-Common-PROJ-ThreadRendezvous". The Javadoc comments inside StringHandoff explain in detail the desired behavior—read this fully. b. StringHandoffImpl.java, TestUltraBasic.java, and TestStringHandoff.java are located in "PROJ_ThreadRendezvous". 3. Only modify the StringHandoffImpl.java file (and this is the only file considered when grading [you can add nested classes if you'd like to, but they must be inside StringHandoffImpl.java]). 4. Plan of attack: a. Before considering anything about timeouts, multiple passers, multiple receivers, shutdown, or any of the tests marked as advanced, design and code the most basic functionality. You can enhance your code later when you've got the core part working. This is definitely the best approach. b. Every time you get a new chunk of code working, make a zip of your source folder, name the zip file something unique, and save it somewhere safe. This way you can always go back to it no matter how much your next steps accidentally mangle things. c. You should not need special classes beyond what you've seen in class. You cannot use "wait helper" utility for the project, but instead must write all the wait-notify code manually. d. the starting code for StringHandoffImpl.java has methods marked as synchronized—keep it that way. We're not using synchronized blocks for the project. e. Have the methods that don't take a timeout call the ones that do passing in a timeout of 0L (zero) and keep these methods this way through your final solution: @Override public synchronized void pass(String msg) throws InterruptedException, ShutdownException, IllegalStateException { pass(msg, 0L); } @Override public synchronized String receive() throws InterruptedException, ShutdownException, IllegalStateException { return receive(0L); } String Rendezvous Project Page 2 of 4 f. For now, the methods that do take a timeout should be written to check for zero and immediately throw a RuntimeException if a non-zero timeout is passed in. We'll fix this later, but it allows us to create compilable and runnable code that can get the basic functionality working without any complexity trying to deal with timeouts: @Override public synchronized void pass(String msg, long msTimeout) throws InterruptedException, TimedOutException, ShutdownException, IllegalStateException { if (msTimeout != 0L) throw new RuntimeException("non-zero timeout is not YET supported"); //... } @Override public synchronized String receive(long msTimeout) throws InterruptedException, TimedOutException, ShutdownException, IllegalStateException { if (msTimeout != 0L) throw new RuntimeException("non-zero timeout is not YET supported"); //... } g. Run TestUltraBasic and get your code to work with it before moving on to the large test suite. Until you get this working, there's no point in adding any complexity. h. Run TestStringHandoff and notice the suite of tests which run in parallel. They run against separate instances of your StringHandoffImpl class, so the parallel testing does not cause any interference. i. In general, attack the tests in the order they are written. ii. The "Points" column shows how many points your code is scoring for passing tests. Ignore the "Valid" column (I need that for my debugging of your submissions) 1. The "Total Points" box near the top is out of 100, but this is just a starting score value and I look at your source code for other potential issues and subtract from there (but no matter what, I won't add deductions to bring your score below 90). iii. Some of the "interrupt check" tests won't pass until non-zero timeouts are actually supported. iv. Get "single item pass and receive" to work first. This is worth a lot of points and the rest won't matter unless this works. v. Next, get "multiple item pass and receive" to work. At this point, definitely zip up your src folder and put that zip file someplace safe. vi. Then add support for timeouts and remove the throwing of a RuntimeException we added earlier and confirm that all of the "interrupt check" tests now pass. vii. Getting everything working to this point puts your starting score at 84. This is all before you have even begun to consider multiple passers, multiple receivers, shutdown, or any of the tests marked as advanced! String Rendezvous Project Page 3 of 4 This is another time to zip up your src folder and put that zip file someplace safe. viii. Next attack multiple passers and multiple receivers. ix. After that, attack shutdown functionality. x. When all that is working, you'll be up to a starting score of 96. Definitely create a zip of your src folder and store it safely. xi. Try the advanced tests one at a time and remember that they may be really difficult to implement and/or may require some significant design changes. 5. Here's the Javadoc generated from the interface description of StringHandoff.java. Read it all carefully, it fully explains how your code needs to work: public interface StringHandoff Rendezvous StringHandoff is used to pass a String from one thread to another. The passer and the receiver meet inside an instance for the hand-off. For example, if pass() is called and there is no receiver waiting, the thread calling pass() will block until a receiver arrives. Similarly, if receive() is called and there is no passer waiting, the thread calling receive() will block until a passer arrives. Timeouts Cause a TimedOutException to be Thrown For this class, methods that can timeout do not return true for success and false for timeout. Methods that take a timeout parameter (pass(String, long) or receive(long)) will throw a TimedOutException if the specified number of milliseconds passes without the hand-off occurring. If the hand-off has completed—regardless of how long it took—no TimedOutException should be thrown. A timeout value of 0L (zero) is used to indicate that the calling thread should wait indefinitely for the condition to be met (never timeout). Negative timeouts should be tolerated and be treated as a very short timeout. TimedOutException is a RuntimeException. One Passer at a Time, One Receiver at a Time There can only be one thread waiting to pass at any given time. If threadA is waiting inside pass() and threadB calls pass(), threadB must throw an IllegalStateException. threadB throwing an exception should not affect threadA at all (threadA should continue waiting). Similarly, there can only be one thread waiting to receive at any given time. If threadA is waiting inside receive() and threadB calls receive(), threadB must throw an String Rendezvous Project Page 4 of 4 IllegalStateException. threadB throwing an exception should not affect threadA at all (threadA should continue waiting). IllegalStateException is a RuntimeException. Shutdown The methods that declare that they may throw a ShutdownException will do so after shutdown() has been called. The shutdown() method itself does not ever throw ShutdownException (in fact, it doesn't ever throw any kind of exception). The shutdown() method may be called multiple times and calling shutdown() multiple times must be harmless. After threadA has already called shutdown(), if threadB calls pass(String), pass(String, long), receive(), or receive(long) threadB must immediately throw ShutdownException. If threadA is waiting inside pass(String), pass(String, long), receive(), or receive(long) and threadB calls shutdown(), threadA should stop waiting and throw ShutdownException. ShutdownException is a RuntimeException. Exception Precedence Exception precedence from highest to lowest is listed below: 1. InterruptedException 2. ShutdownException 3. IllegalStateException 4. TimedOutException Example 1: while threadA is waiting, if both of these happen before threadA can re-acquire the lock to get back from wait: i) threadB calls shutdown() and then ii) threadC interrupts threadA, the result should be that threadA throws InterruptedException. Example 2: while threadA is waiting with a timeout, if both of these happen before threadA can re-acquire the lock to get back from wait: i) threadB calls shutdown() and then ii) threadA times out, the result should be that threadA throws ShutdownException. Example 3: while threadA is waiting inside pass(), if both of these happen before threadA can re-acquire the lock to get back from wait: i) threadB calls shutdown() and then ii) threadC calls pass(), the result should be that threadC should throw ShutdownException< (not IllegalStateException!) AND threadA should throw ShutdownException.
PROJ_ThreadRendezvous/.classpath PROJ_ThreadRendezvous/.project PROJ_ThreadRendezvous org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature PROJ_ThreadRendezvous/.settings/org.eclipse.jdt.core.prefs eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=11 PROJ_ThreadRendezvous/build/eclipse/classes/com/abc/handoff/StringHandoffImpl.class package com.abc.handoff; public synchronized class StringHandoffImpl implements com.abc.pp.stringhandoff.StringHandoff { public void StringHandoffImpl(); public synchronized void pass(String, long) throws InterruptedException, com.programix.thread.TimedOutException, com.programix.thread.ShutdownException, IllegalStateException; public synchronized void pass(String) throws InterruptedException, com.programix.thread.ShutdownException, IllegalStateException; public synchronized String receive(long) throws InterruptedException, com.programix.thread.TimedOutException, com.programix.thread.ShutdownException, IllegalStateException; public synchronized String receive() throws InterruptedException, com.programix.thread.ShutdownException, IllegalStateException; public synchronized void shutdown(); public Object getLockObject(); } PROJ_ThreadRendezvous/build/eclipse/classes/com/abc/handoff/test/TestStringHandoff$1.class package com.abc.handoff.test; synchronized class TestStringHandoff$1 implements com.abc.pp.stringhandoff.tests.StringHandoffFactory { PROJ_ThreadRendezvous/build/eclipse/classes/com/abc/handoff/test/TestStringHandoff.class package com.abc.handoff.test; public synchronized class TestStringHandoff { PROJ_ThreadRendezvous/build/eclipse/classes/com/abc/handoff/test/TestUltraBasic$BasicPasser.class package com.abc.handoff.test; synchronized class TestUltraBasic$BasicPasser { PROJ_ThreadRendezvous/build/eclipse/classes/com/abc/handoff/test/TestUltraBasic$BasicReceiver.class package com.abc.handoff.test; synchronized class TestUltraBasic$BasicReceiver { PROJ_ThreadRendezvous/build/eclipse/classes/com/abc/handoff/test/TestUltraBasic.class package com.abc.handoff.test; public synchronized class TestUltraBasic { PROJ_ThreadRendezvous/src/java/com/abc/handoff/StringHandoffImpl.java PROJ_ThreadRendezvous/src/java/com/abc/handoff/StringHandoffImpl.java package com.abc.handoff; import com.abc.pp.stringhandoff.*; import com.programix.thread.*; public class StringHandoffImpl implements StringHandoff {     public StringHandoffImpl() {     }     @Override     public synchronized void pass(String msg, long msTimeout)         throws InterruptedException, TimedOutException, ShutdownException, IllegalStateException {     }     @Override     public synchronized void pass(String msg) throws InterruptedException, ShutdownException, IllegalStateException {     }     @Override     public synchronized String receive(long msTimeout)         throws InterruptedException, TimedOutException, ShutdownException, IllegalStateException {         return null;     }     @Override     public synchronized String receive() throws InterruptedException, ShutdownException, IllegalStateException {         return null;     }     @Override     public synchronized void shutdown() {     }     @Override     public Object getLockObject() {         return this;     } } PROJ_ThreadRendezvous/src/java/com/abc/handoff/test/TestStringHandoff.java PROJ_ThreadRendezvous/src/java/com/abc/handoff/test/TestStringHandoff.java package com.abc.handoff.test; import com.abc.handoff.*; import com.abc.pp.stringhandoff.*; import com.abc.pp.stringhandoff.tests.*; import com.abc.pp.stringhandoff.tests.gui.*; public class TestStringHandoff {     public static void main(String[] args) {         GuiTestPPStringHandoff.runTests(             "Testing of StringHandoff",             true,             new StringHandoffFactory() {                 @Override                 public StringHandoff create() {                     return new StringHandoffImpl();                 }             });     } } PROJ_ThreadRendezvous/src/java/com/abc/handoff/test/TestUltraBasic.java PROJ_ThreadRendezvous/src/java/com/abc/handoff/test/TestUltraBasic.java package com.abc.handoff.test; import com.abc.handoff.*; import com.abc.pp.stringhandoff.*; import com.programix.thread.*; import com.programix.util.*; public class TestUltraBasic {     private static void testPasserShowsUpFirst() throws InterruptedException {         outln("===============================");         outln("Entering testPasserShowsUpFirst...");         StringHandoff handoff = new StringHandoffImpl();         BasicPasser passer = new BasicPasser(handoff, "apple", 200L, "Passer-A");         BasicReceiver receiver = new BasicReceiver(handoff, "apple", 1200L, "Receiver-A");         Thread.sleep(2500L); // should be plenty of time for the handoff to have occurred         passer.stopRequest();         receiver.stopRequest();         if (!passer.waitUntilStopped(2000L)) outln("!!! passer ignored stopRequest and is still stuck running");         if (!receiver.waitUntilStopped(2000L)) outln("!!! receiver ignored stopRequest and is still stuck running");         outln("... leaving testPasserShowsUpFirst");         outln("===============================");     }     private static void testReceiverShowsUpFirst() throws InterruptedException {         outln("===============================");         outln("Entering testReceiverShowsUpFirst...");         StringHandoff handoff = new StringHandoffImpl();         BasicReceiver receiver = new BasicReceiver(handoff, "banana", 200L, "Receiver-B");         BasicPasser passer = new BasicPasser(handoff, "banana", 1200L, "Passer-B");         Thread.sleep(2500L); // should be plenty of time for the handoff to have occurred         passer.stopRequest();         receiver.stopRequest();         if (!passer.waitUntilStopped(2000L)) outln("!!! passer ignored stopRequest and is still stuck running");         if (!receiver.waitUntilStopped(2000L)) outln("!!! receiver ignored stopRequest and is still stuck running");         outln("... leaving testReceiverShowsUpFirst");         outln("===============================");     }     private static void outln(String fmt, Object... args) {         ThreadTools.outln(String.format(fmt, args));     }     private static void out(Throwable t) {         String[] line = StringTools.stackTraceToStringArray(t);         for ( int i = 0; i < line.length; i++ ) {             outln(line[i]);         }     }     public static void main(String[] args) {         try {             testPasserShowsUpFirst();             Thread.sleep(500);             testReceiverShowsUpFirst();         } catch (Exception x) {             out(x);         }     }     private static class BasicPasser {         private final StringHandoff handoff;         private final String stringToPass;         private final long msDelayBeforePassing;         private final Thread internalThread;         private volatile boolean keepGoing;         public BasicPasser(StringHandoff handoff,                            String stringToPass,                            long msDelayBeforePassing,                            String name) {             ObjectTools.paramNullCheck(handoff, "handoff");             this.handoff = handoff;             this.stringToPass = stringToPass;             this.msDelayBeforePassing = Math.max(1, msDelayBeforePassing);             keepGoing = true;             internalThread = new Thread(() -> runWork(), name != null ? name : "Passer");             internalThread.start();         }         private void runWork() {             boolean wasInterrupted = false;             try {                 outln("%s starting", Thread.currentThread().getName());                 outln("Taking a %d ms nap before calling pass(%s)",                     msDelayBeforePassing, StringTools.quoteWrap(stringToPass));                 Thread.sleep(msDelayBeforePassing);                 if (!keepGoing) return;                 outln("Attempting to call pass(%s)", StringTools.quoteWrap(stringToPass));                 handoff.pass(stringToPass);                 outln("... finished passing");             } catch ( InterruptedException x ) {                 // ignore and let thread die                 wasInterrupted = true;             } catch ( Throwable x ) {                 out(x);             } finally {                 outln("%s finished%s", Thread.currentThread().getName(), wasInterrupted ? " (was interrupted)" : "");             }         }         public void stopRequest() {             keepGoing = false;             internalThread.interrupt();         }         public boolean waitUntilStopped(long msTimeout) throws InterruptedException {             internalThread.join(msTimeout);             return !internalThread.isAlive();         }         private static void outln(String fmt, Object... args) {             ThreadTools.outln(String.format(fmt, args));         }         private static void out(Throwable t) {             String[] line = StringTools.stackTraceToStringArray(t);             for ( int i = 0; i < line.length; i++ ) {                 outln(line[i]);             }         }     }  // type BasicPasser     private static class BasicReceiver {         private final StringHandoff handoff;         private final String expectedMessage;         private final long msDelayBeforeAttemptingToReceive;         private final Thread internalThread;         private volatile boolean keepGoing;         public BasicReceiver(StringHandoff handoff,                              String expectedMessage,                              long msDelayBeforeAttemptingToReceive,                              String name) {             ObjectTools.paramNullCheck(handoff, "handoff");             this.handoff = handoff;             this.expectedMessage = expectedMessage;             this.msDelayBeforeAttemptingToReceive = Math.max(1, msDelayBeforeAttemptingToReceive);             keepGoing = true;             internalThread = new Thread(() -> runWork(), name != null ? name : "Passer");             internalThread.start();         }         private void runWork() {             boolean wasInterrupted = false;             try {                 outln("%s starting", Thread.currentThread().getName());                 outln("Taking a %d ms nap before calling receive()", msDelayBeforeAttemptingToReceive);                 Thread.sleep(msDelayBeforeAttemptingToReceive);                 if (!keepGoing) return;                 outln("Attempting to call receive()");                 String result = handoff.receive();                 outln("... back from receive() with message: %s, %s", StringTools.quoteWrap(result),                     StringTools.isSame(result, expectedMessage) ? "as expected (PASSED)" :                         String.format("but expected: %s, (FAILED)", StringTools.quoteWrap(expectedMessage)));             } catch ( InterruptedException x ) {                 // ignore and let thread die                 wasInterrupted = true;             } catch ( Throwable x ) {                 out(x);             } finally {                 outln("%s finished%s", Thread.currentThread().getName(), wasInterrupted ? " (was interrupted)" : "");             }         }         public void stopRequest() {             keepGoing = false;             internalThread.interrupt();         }         public boolean waitUntilStopped(long msTimeout) throws InterruptedException {             internalThread.join(msTimeout);             return !internalThread.isAlive();         }         private static void outln(String fmt, Object... args) {             ThreadTools.outln(String.format(fmt, args));         }         private static void out(Throwable t) {             String[] line = StringTools.stackTraceToStringArray(t);             for ( int i = 0; i < line.length; i++ ) {                 outln(line[i]);             }         }     }  // type BasicReceiver } PROJ_ThreadRendezvous/src/PossibleOutputFromTestUltaBasic.txt 00:00:00.000|main |=============================== 00:00:00.004|main |Entering testPasserShowsUpFirst... 00:00:00.012|Passer-A |Passer-A starting 00:00:00.012|Passer-A |Taking a 200 ms nap before calling pass("apple") 00:00:00.013|Receiver-A|Receiver-A starting 00:00:00.013|Receiver-A|Taking a 1200 ms nap before calling receive() 00:00:00.216|Passer-A |Attempting to call pass("apple") 00:00:01.213|Receiver-A|Attempting to call receive() 00:00:01.214|Passer-A |... finished passing 00:00:01.214|Passer-A |Passer-A finished 00:00:01.214|Receiver-A|... back from receive() with message: "apple", as expected (PASSED) 00:00:01.215|Receiver-A|Receiver-A finished 00:00:02.513|main |... leaving testPasserShowsUpFirst 00:00:02.513|main |=============================== 00:00:03.013|main |=============================== 00:00:03.013|main |Entering testReceiverShowsUpFirst... 00:00:03.014|Receiver-B|Receiver-B starting 00:00:03.014|Passer-B |Passer-B starting 00:00:03.014|Receiver-B|Taking a 200 ms nap before calling receive() 00:00:03.014|Passer-B |Taking a 1200 ms nap before calling pass("banana") 00:00:03.215|Receiver-B|Attempting to call receive() 00:00:04.223|Passer-B |Attempting to call pass("banana") 00:00:04.224|Passer-B |... finished passing 00:00:04.224|Receiver-B|... back from receive() with message: "banana", as expected (PASSED) 00:00:04.224|Passer-B |Passer-B finished 00:00:04.224|Receiver-B|Receiver-B finished 00:00:05.514|main |... leaving testReceiverShowsUpFirst 00:00:05.514|main |===============================

Related Questions

Similar orders to Project in Java due for next week
10
Views
0
Answers
Project to implement a scanner, recursive descent parser, de-parser for a small programming language Hawk

In this project you are to implement a scanner and a recursive descent parser, and a de-parser for a small programming language (let’s call it Hawk). Your program will take as input a program written in the provided language and produce a parse tree in the form of a table. In addition to generating the parse tree, your program must generate the proper errors when encountered. After generating the tree, you need to write a program that de-parses the tree into the original code that generated it.

The following is the grammar that you will use:

Rule 01: PROGRAM -> program DECL_SEC begin STMT_SEC end;

Rule 02: DECL_SEC -> DECL | DECL DECL_SEC

Rule 03: DECL -> ID_LIST : int ;

Rule 04: ID_LIST -> ID | ID , ID_LIST

Rule 05: ID -> a|b|c|...| z | A | ... | Z

Rule 06: STMT_SEC -> STMT | STMT STMT_SEC

Rule 07: STMT -> ASSIGN | IFSTMT | WHILESTMT | INPUT | OUTPUT

Rule 08: ASSIGN -> ID := EXPR ;

Rule 09: IFSTMT -> if COMP then STMT_SEC end if ; |

if COMP then STMT_SEC else STMT_SEC end if ;

Rule 1...

31
Views
0
Answers
Use Java to add and subtract exact time
NEED BY 9/30 AT 3:00AM!!! The website will not allow me to set that time. Please follow instructions very carefully and program in Java. Please complete both BasicTime and PreciseTime. Please code using originality... No forms of plagiarism....
42
Views
0
Answers
code in p5.js please. reply if you can help
1. Six-part drawing. The wall is divided horizontally and vertically into six equal parts. 1st part: On red, blue horizontal parallel lines, and in the center, a circle within which are yellow vertical parallel lines; 2nd part: On yellow, red horizontal parallel lines, and in the center, a square within which are blue vertical parallel lines; 3rd part: On blue, yellow horizontal parallel lines, and in the center, a triangle within which are red vertical parallel lines; 4th part: On red, yellow horizontal parallel lines, and in the center, a rectangle within which are blue vertical parallel lines; 5th part: On yellow, blue horizontal parallel lines, and in the center, a trapezoid within which are red vertical parallel lines; 6th part: On blue, red horizontal parallel lines, and in the center, a parallelogram within which are yellow vertical parallel lines. The horizontal lines do not enter the figures 2. Draw a wall with “irregular wavy color bands”. Hint: you can use curveVertex and random functions in p5js library. (2 mark...
39
Views
0
Answers
code in p5.js for three questions.
I need code in p5.js for given questions in attached file. Please reply if you can help. thx Six-part drawing. The wall is divided horizontally and vertically into six equal parts. 1st part: On red, blue horizontal parallel lines, and in the center, a circle within which are yellow vertical parallel lines; 2nd part: On yellow, red horizontal parallel lines, and in the center, a square within which are blue vertical parallel lines; 3rd part: On blue, yellow horizontal parallel lines, and in the center, a triangle within which are red vertical parallel lines; 4th part: On red, yellow horizontal parallel lines, and in the center, a rectangle within which are blue vertical parallel lines; 5th part: On yellow, blue horizontal parallel lines, and in the center, a trapezoid within which are red vertical parallel lines; 6th part: On blue, red horizontal parallel lines, and in the center, a parallelogram within which are yellow vertical parallel lines. The horizontal lines do not enter the figures...