Home / Expert Answers / Computer Science / part-1-make-a-box-that-can-hold-any-network-node-this-first-part-checks-that-pa829

(Solved): Part 1: Make a box that can hold any network node This first part checks that ...



Part 1: Make a box that can hold any network node
This first part checks that you know how to use generics, write JavaDocs, aPart 2: Nodes and Numbers
This second part of the project checks that you know how to use command line arguments and write baFrom in your user directory:
\( \begin{array}{ll}\text { Compile: } & \text { javac *.java } \\ \text { Run Part 1: } & \text???????

Part 1: Make a box that can hold any network node This first part checks that you know how to use generics, write JavaDocs, and use the basic command line tools you'll use throughout the semester. You need to write a class called TwoItemBox (in a file called TwoI temBox. java that you create). This class has a constructor that takes two items (of any type) and puts them in the box. You also need a method called getItem1 () and getItem2 () which provide the items back to the user but does not remove them from the box (this is an "accessor", if you remember, sometimes called a "getter"). Make sure to comment your code as you go in proper JavaDoc style. To check that you've got the right idea, we've provided a class called Twor temBoxDemo - java which shows creating two different box objects that store different things (a client and a server, a router and a switch). You should not alter this class to "make it work", but rather alter your box to allow the provided code to work. You can use the command "java TwortemBoxDemo" to run the testing code defined in main (). You could also edit this main () to perform additional testing (we won't be using TwoI temBoxDemo for testing, it's just a demo for you). Note that JUnit test cases will not be provided for TwoItemBox, but feel free to create JUnit tests for yourself. A part of your grade will be based on automatic grading using test cases made from the specifications provided. TL;DR You're making a box (TwoItemBox) and using JavaDoc comments. There's test code in TwoItemBoxDemo. Checking That You've Got Stvle Every professional developer needs to adhere to a coding style (indentation, variable naming, etc.). This is non-optional in of professional settings (aka. "jobs"). Normally, in school, a grader checks your style manually, but this is very inefficient since you only get feedback after your project is completed (not while you're writing), and it's very hard for someone to manually check these things. We're going to help move you along the path to "coding with style" this semester. We have provided you with a command line tool that checks your style for you: checkstyle (https://checkstyle.org). This tool has plugins for Eclipse, NetBeans, jGRASP, and many others (see their website), but there is also a command line interface (CLI) which has been provided with this project (checkstyle .jar). This automatic checker is similar to ones used at large companies (like Google, Oracle, and Facebook). If you're curious, we're using a subset of Google's style requirements for this class. The provided cs310code . xm1 checks for common coding convention mistakes (such as indentation and naming issues). You can use the following to check your style: java -jar checkstyle.jar -c [style.xml file] [userDirectory]/*.java For example, for a user directory 001-yourusername-p0 checking for JavaDoc mistakes I would use: Note: if you have a lot of messages from checkstyle, you can add the following to the end of the command to output it to a file called out.txt: > out.txt If checkstyle finds nothing wrong you'll see "Starting audit... Audit done." and nothing else. Checking Your JavaDoc Comments You should verify that your JavaDoc comments adhere to the proper format (especially if you're new to writing JavaDocs). We've provided a second checkstyle file ( comments . xm1) that looks for JavaDoc issues and in-line comment indentation issues. You can run it the same way as cs310code. , for example: java -jar checkstyle.jar -c cs310comments.xml 001-yourusername-p0/*.java Part 2: Nodes and Numbers This second part of the project checks that you know how to use command line arguments and write basic Java code (including exception handling), and gives you more practice writing JavaDocs and using checks tyle. You'll also be able to see and use JUnit tests (such as the ones we use when grading). Specification: Write a program (Nodes . java). This program should print the numbers from 1 to (inclusive), space separated, but for numbers 3 and 12 prints "router", for odd numbers prints "client", and for even numbers prints "server is a command line argument to the program. Don't forget to document as you go. Example program run (coloring add. for readability): maha@L-MAC-N04012 s23 \% java Nodes 10 Client Server Router Server Client Server Client Server Client Server maha@L-MAC-N04012 s23 \% java Nodes 20 Client Server Router Server Client Server Client Server Client Server Client Router Client Server Client Server Client Server Client Server maha@L-MAC-N04012 s23 \% java Nodes 15 Client Server Router Server Client Server Client Server Client Server Client Router Client Server Client Checking for Invalid Input Your program should print the following (exactly) if the command line argument is missing, if the argument is not a positive number, or if too many arguments are given. This message should be sent to System,err not system, out. Example commands which generate this error: java Nodes java Nodes 0 java Nodes 11 java Nodes cool Error message: One positive number required as a command line argument. Example Usage: java Nodes [number] Exactly Matching Output Seven unit tests have been provided to automate checking that you are exactly matching the output required (NodesTest. Java) since it is hard to eyeball differences in text. To run these tests, navigate to the directory above you user directory (from your user directory type cd .. to go up one directory) and do the following... Compile and run the tests with the following in Windows: javac -cp .;junit-4.11.jar; [userDirectory] Nodestest.java java -cp . jjunit-4.11.jar; [userDirectory] Nodestest Or for Linux/Mac, replace all the semicolons wit colons in the classpath: javac -cp . : junit-4.11.jar:[userDirectory] Nodestest.java java -cp : junit-4.11.jar:[userDirectory] Nodes Check Your Stvle and JavaDocs Run both checkstyle files again on this new program to verify you got those basics down. Command Reference All commands are from inside your user folder and assume you left the style items and dictionaries in an outer folder (since you unzipped project0.zip into a single place as suggested and didn't move around any files). From in your user directory: From above your user directory: Style Checker: java -jar checkstyle.jar -c cs310code. [userDirectory]/*, java Comments Checker: java -jar checkstyle.jar -c cs310comments.xml [userDirectory]/*. java Compile Unit Tests: javac -cp . junit-4.11.jar; [userDirectory] NodesTest.java Run Unit Tests: java -cp . ;junit-4.11.jar; [userDirectory] Nodestest Or for Linux/Mac users, make sure that you use : instead of ; for the classpath (the argument to ).


We have an Answer from Expert

View Expert Answer

Expert Answer


/** * A class that holds two items of any type. * * @param the type of items to be stored */public class TwoItemBox { private T item1
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe