Question: java program Basic Procedures You must: Have code that compiles with the command: javac *.java in your user directory Have code that runs with the

java program

Basic Procedures You must: Have code that compiles with the command: javac *.java in your user directory Have code that runs with the following command for part 1: java BoxUsageDemo Have code that runs with the following command for part 2: java AppleOrange [number] You may: Add additional methods and variables not specifically mentioned in the project description, however these methods and variables must be private. You may NOT: Make your program part of a package. Add additional public methods or variables. Use any built in Java Collections Framework classes anywhere in your program (e.g. no ArrayList , LinkedList , HashSet , etc.). Use any arrays anywhere in your program (except args in main() ). Add any additional import statements (or use the fully qualified name to get around adding import statements). Add any additional libraries/packages which require downloading from the internet.

Part 1: Make a box that can hold anything This first part checks that you know how to use generics, write JavaDocs, and use the basic command line tools youll use throughout the semester. You need to write a class called SingleItemBox (in a file called SingleItemBox.java that you create). This class has a constructor that takes a single item (of any type) and puts it in the box. You also need a method called getItem() which provides the item back to the user but does not remove it 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 youve got the right idea, weve provided a class called BoxUsageDemo.java which shows creating three different boxes that store different things (an apple, a banana, and a cat). 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 BoxUsageDemo " to run the testing code defined in main() . You could also edit this main() to perform additional testing (we wont be using BoxUsageDemo for testing, its just a demo for you). Note that JUnit test cases will not be provided for SingleItemBox , 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 Youre making a box ( SingleItemBox ) and using JavaDoc comments. Theres test code in BoxUsageDemo . Checking That Youve Got Style Every professional developer needs to adhere to a coding style (indentation, variable naming, etc.). This is non-optional in 99.99999% 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 youre writing), and its very hard for someone to manually check these things. Were 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 youre curious, were using a subset of Googles style requirements for this class. The provided cs310code.xml 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-krusselc-p0 checking for JavaDoc mistakes I would use: java -jar checkstyle.jar -c cs310code.xml 001-krusselc-p0/*.java 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 youll 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 youre new to writing JavaDocs). Weve provided a second checkstyle file ( cs310comments.xml ) that looks for JavaDoc issues and in-line comment indentation issues. You can run it the same way as cs310code.xml , for example: java -jar checkstyle.jar -c cs310comments.xml 001-krusselc-p0/*.java TL;DR There are some tools you need to try out. They are provided. They help you code more professionally. Dimitriadis/Russell Project 0: Project Skills Check CS310 - Spring 2021 4 Part 2: Fruit 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 it gives you more practice writing JavaDocs and using checkstyle . Youll also be able to see and use JUnit tests (such as the ones we use when grading). Specification: Write a program ( AppleOrange , that lives in AppleOrange.java ). This program should print the numbers from 1 to X (inclusive), space separated, but for multiples of 3 print apple instead of the number, for multiples of 7 print orange instead of the number, and for the multiples of both 3 and 7 print appleorange (no space) instead of the number. X is a command line argument to the program. Dont forget to document as you go. Example program run (coloring added for readability): > java AppleOrange 10 1 2 apple 4 5 apple orange 8 apple 10 > java AppleOrange 25 1 2 apple 4 5 apple orange 8 apple 10 11 apple 13 orange apple 16 17 apple 19 20 appleorange 22 23 apple 25 > java AppleOrange 50 1 2 apple 4 5 apple orange 8 apple 10 11 apple 13 orange apple 16 17 apple 19 20 appleorange 22 23 apple 25 26 apple orange 29 apple 31 32 apple 34 orange apple 37 38 apple 40 41 appleorange 43 44 apple 46 47 apple orange 50 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 AppleOrange > java AppleOrange 0 > java AppleOrange 1 1 > java AppleOrange apple Error message: One positive number required as a command line argument. Example Usage: java AppleOrange [number] Exactly Matching Output Seven unit tests have been provided to automate checking that you are exactly matching the output required ( AppleOrangeTest.java ) since it is hard to eyeball differences in text. To run these tests, navigate to the directory above your 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] AppleOrangeTest.java java -cp .;junit-4.11.jar;[userDirectory] AppleOrangeTest Or for Linux/Mac, replace all the semicolons wit colons in the classpath: javac -cp .:junit-4.11.jar:[userDirectory] AppleOrangeTest.java java -cp .:junit-4.11.jar:[userDirectory] AppleOrangeTest Check Your Style and JavaDocs Run both checkstyle files again on this new program to verify you got those basics down. TL;DR You need to make a program (AppleOrange) with exactly output. JUnit tests are provided (AppleOrangeTest).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!