QuestionQuestion

Question 1: (Unicycle.java UnicycleTester.java) (20 marks) In the project (question1 package) you are given object classes for Frames and Wheels. Your job is to create a new Object class Unicycle that has as data field a Frame object and a Wheel object. It also has a String data field which represents the customer for whom the Unicycle is being built. I suggest taking a few minutes to look over Frame and Wheel to see what they do. Your Unicycle class should have the following:
A default, no argument constructor that creates a unicycle with your name as the customer and a frame/wheel combination of your choice.
A fully-argumented constructor that takes in a wheel, frame and customer name. A copy constructor that creates a new Unicycle that has the same properties as the incoming argument Unicycle.
Get and set methods for all of the data fields.
An appropriate toString method.
The idea here is to practice deep-copy for your constructors, set methods and return methods.
Wherever appropriate you must avoid using shallow copy. Write a hard-coded tester to make sure that your objects are working properly and that there are no "data leaks" (this is what happens when one object changes and those changes are reflected in another).
Bonus: Create an interactive tester class that collects from the user all of the information required to create their own custom Unicycle and allows them to modify if they choose to.

Question 2. (StringTools.java, StringToolsTester.java) Write a class of static methods that accomplish the following tasks. In all cases do not look for built-in methods that accomplish the task, use loops as well as String and Character methods to get the tasks done.
reverse(String s) : String
-take a String as an argument and return the String reversed. Eg. "Hello" would be returned as "olleH".
binaryToDecimal(String s) : int
-take a String as an argument and return the decimal equivalent as an integer. If any of the characters are neither zero nor one return null. Eg. "1000" would return 8. "10001" would return 17. "111111" would return 63. "111112" would return - 1. "100001.1" would return - -1.
initials(String s) : String
-take a String as an argument and return a properly "initialized" and capitalized name. If the String does not contain exactly three names return null. Eg. "James tiBeriUs kiRK" would return "J. T. Kirk". "jean luc picard" would return "J. L. Picard" AaroN LANGille" would return null.
mostFrequent(String s) : char
-take a String and return the Character that occurs most frequently. In the event of a tie, return the last character that was checked in the tie.
replaceSubString(String s1, String s2, String s3) : String
-take three Strings as arguments. The first String is the user's "text". The second String is a pattern to look for.
Make all Strings lowercase in the method to facilitate search and replace. The third String is a pattern to replace the second String with. Eg: "the dog jumped over the fence" as the first String, "the" as the second and "that" as the third. Returned String is "that dog jumped over that fence".
Write a tester class that shows off all of your methods. Be sure that errors (input that results in null) are handled properly.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

package question1;

/**
* This class encapsulates the frame for a unicycle. This class is immutable
* meaning, once a frame has been created it cannot be changed.
* @author aaron
*
*/

public class Frame {

private int height;
private String colour;

/**
* No-argument constructor that creates a 12" blue frame.
*/
public Frame(){
this(12, "blue");
}

/**
* Fully argumented constructor allowing for different heights
* and colours. The object is only constructed if a valid height
* argument is provided. Colour is not checked.
*
* @param height height of the frame.
* @param colour colour of the frame.
*/
public Frame(int height, String colour){
//Since the constructor and the setFrame() method do the same
//work i decided to consolidate.
setFrame(height, colour...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$60.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats