Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Lab 1 - Remember Java? Name(s): Date:     Lab 1 - Remember Java? Algorithms & Data Structures II CSC 1052   Dr. Tom Way Introduction This lab is designed to refresh what you know about Java and get you ready for the programming challenges ahead. You should do this lab independently, though it's ok to discuss it with classmates as long as you aren't copying each other's work. When completed, submit your results to Blackboard for this specific assignment as described below. Objectives Install and gain experience with Eclipse. Practice with designing classes. Practice with strings, arrays and static methods. Practice with using and manipulating strings and with common array algorithms. Worth 100 points Due Tuesday, August 30, 2021 by 11:59 pm Lab Steps Part A - Up and Running Follow the instructions in the Using Eclipse topic in Rephactor to install the Eclipse IDE software on your computer.   Create a folder on your computer to use for all the materials you will create for this course. A suggested approach is to create a folder called CSC 1052 and then a separate subfolder inside that for each assignment, in this case Lab 1.   Start Eclipse and create a new Java project entitled -lab1. For example, tway-lab1.   Note: We will follow this project naming convention for all labs. Another note: If using a recent version of Eclipse, you may be presented with a Create module-info.java pop-up dialog. For the purposes of this course, always select Don�t Create.   Optional Tweaks: You can adjust positioning of curly braces from the default end-of-line position (as well as other auto-formatting in Eclipse) by changing settings in Window > Preferences > Java > Code Style > Formatter by clicking Edit and under Brace Positions make them all "Next Line." Or, you can import CSC1052JavaFormatter.xml into Eclipse from the Formatter dialog.   Get acquainted with Eclipse by typing in, compiling, and running a basic Hello, World! program. Once satisfied you understand the basics of using Eclipse you can trash your Hello, World! program. Part B - FM Radio (40 points) For this part of the lab, you will reinforce what you know about classes and objects by designing and using a class that contains a number of methods.   Inside the project you created in Part A, create a class called FMRadio that will represent a virtual radio object. This object will have the following capabilities and functionality:   A user should be able to turn a radio on or off.   A radio object should be able to keep track of current volume level and frequency it is tuned to. Feel free to think about additional meaningful attributes (instance/state variables) and then add those, too.   If the radio is on, then a user should be able to increase or decrease the volume as well as tune it by changing the frequency up or down.   Radios have a maximum and minimum volume level as well as maximum and minimum frequency. The frequency band for FM radio is typically 88 to 108 MHz and most digital tuners allow frequency increment and decrement in steps of 0.1 MHz.   Think of what constructor(s) would be meaningful and then define those.   Feel free to add getters/setters (a.k.a., accessors/mutators). For example, a user should be able to check or change the current frequency and volume.   Include a toString method so that meaningful information about a radio can be printed out.   Write a separate class TestRadio that contains a main method. It should create at least one radio object and simulate using the radio with the functionality provided by your FMRadio class above. An example test sequence may be:   Create the radio using one of your constructors Print out its information (toString) Turn on the radio Print out its information (toString) Increase the volume a number of times Get the current volume and print it out Change the frequency a number of times Get the current frequency and print it out Set the volume and frequency to specific values Print out its information (toString) Turn off the radio Print out its information (toString) REPEAT this sequence for any other constructors Part C - Useful Methods (60 points) In this part of the lab, you will reinforce what you know about Java strings, arrays and common array algorithms, and also gain experience with static methods. Under the project created above, create a another class called UsefulMethods. Within this class define the following static methods:   (10 points) static int arrayMax(int[] arr) that takes in an array of integers and returns the maximum of those integers.   (10 points) static int [] arrayHalf(int[] arr) that takes in an array of integers and returns a new array containing the first half of the elements in the array. If there are odd number of elements, return the first half including the middle element.   (40 points) static String pigify(String word) that takes in a word as a string and returns its Pig Latin translation. Simplified grammar rules for Pig Latin translation are as follows:   If the word begins with a vowel, add "yay" at the end of the word. For example, "apple" becomes "appleyay" and "egg" becomes "eggyay"   Otherwise, find the first occurrence of a vowel in the word, move all the characters before the vowel (i.e., a substring) to the end of the word, and add "ay". For example, "stupid" becomes "upidstay", "nix" becomes "ixnay" and "grr" becomes "grray".   What about these words: "ear" and "year", "our" and "your", "awl" and "yawl", "ick" and "yick" ?   Tip: The String class in Java has many useful methods. Check out the Strings topic in Rephactor and the online Java API documentation for ideas.   Add a main method to this class and provide test cases for the methods above that fully demonstrate the capabilities of your UsefulMethods class. Lab Submission When you have completed this lab, find the Lab 1 assignment on Blackboard and submit two things:   Zip Archive: A zip archive of your project using the same name as the project for the zip archive (e.g., tway-lab1.zip). See the online article How to Use Eclipse IDE to Export Project Based on Java, which is also linked from our class Resources page.   Test Runs: A separate text document called testruns.txt containing complete test runs of your programs, all copied and pasted into this single testruns.txt file. Be sure to include at least a title of "Lab 1 Test Runs", your name and date at the beginning of the file.