fisrt one is bicycle.java second code is bicycleapp.java can anyone help this??? please save my life Before you begin, DOWNLOAD the files “Lab8_Bicycle.java” and “Lab8_BicycleApp.java” from Canvas to your network drive (not the local hard drive or desktop). Once you have the files saved, RENAME THE FILES Bicycle.java and BicycleApp.java then open each file. 1) Look at the Bicycle class. Two of the many data properties we could use to define a bike are its color and the gear it is currently in. Since both properties are private, we need methods to be able to change the values for these data properties. Read through the code provided for these methods. 2) Within the Bicycle class, fill in the code need to create the 4 overloaded constructors and the code need to change the color and gear of a bike within the set methods. 3) Next, within the Bicycle class, comment out the last 2 methods (display…) and create a single ‘toString’ method that will have nothing passed to it and returns a string that can be used within a println statement to display the data properties of a given Bicycle object in the same format as the two given methods. Your toString methods will NOT contain any println methods. Method signature: public String toString() …Make sure that the Bicycle class compiles (not executes) before continuing… 4) Finish the BicycleApp class by doing the following: - Create an array that will hold 4 Bicycle Objects - Use your set methods to change the gear and color of the first bike - Display the new current state of all bicycles in the array using your toString method …Compile and Run your program to make sure it works properly before continuing… Part 2: Required unless otherwise specified by your GTA 5) To the Bicycle class, add a method with the following signature: public boolean equals (Bicycle other) - Methods returns true if the color and gear of the calling object (this) is the same as the color and gear of the bike passed to the method (other), otherwise returns false 6) Within the BicycleApp class, create another bicycle object (newBike) that is NOT part of the array. Color is purple and the gear is 1. - Use the equals method to determine if newBike is equal to any other bike in the array. If so, display “newBike object matches a current bike in the array” otherwise display "newBike object does NOT match a current bike in the array" Defines the Bicycle class containing the following data propeties: 1) color of the bike 2) current gear the bike is in Includes 4 constructors, a setColor and setGear methods, and toString method Part 2 modification adds an equals method */ import java.util.Scanner; public class Bicycle {//instance variables private int gear; private String color; // Constructor #1: set default gear to 1 and the color to primer gray public Bicycle () { } // end 'default' no-argument constructor // Constructor #2: sets the gear to a passed-in value // and color to same default color as constructor #1 public Bicycle (int newGear) { } // end one-argument constructor (sets the gear) // Constructor #3: sets the color to the passed-in value // and the gear to the same default gear as constructor #1 public Bicycle (String newColor) { } // end one-argument constructor (sets the color) // Constructor #4: sets the gear to the passed-in value // and sets the color as the passed-in value public Bicycle (int newGear, String newColor) { } // end two-argument constructor (sets gear and color) //Sets the private data property 'gear' with the value passed in public void setGear(int newGear) { } //end of method setGear //Sets the private data property 'color' with the value passed in public void setColor(String newColor) { } //end of method setGear //This method displays the value of the String variable 'color' public void displayColor() { System.out.println ("The color of the bike is " + color); } //end method displayColor //This method displays the value of the int variable 'gear' public void displayGear() { System.out.println ("The bike is in gear #" + gear); } //end method displayGear // Comment out the two methods above... // Create a toString method that returns a String that can // be used to display the data properties of a bicycle in the // same format you are commenting out // Create an equals method that returns true if the bikes are // in the same gear and are the same color, otherwise returns false... } //end class Bicycle
/* BicycleApp.java - application class for the Bicycle class
Creates an array of 4 bike objects, displays data
properties of all using the toString method,
changes the gear and color on bike[0] then
displays
the new data properties of all using the toString
method
Part 2 - Create another bicycle object that is NOT
part of the array
and use the equals method to determine if it is equal
to any of the
other bikes in the array
*/
import java.util.*;
public class BicycleApp
{
public static void main(String[] args)
{
// declare an array of 4 Bicycle objects
// Instantiate the 4 bike
objects (Done for you)
bikes[0] = new Bicycle();
bikes[1] = new Bicycle(6);
bikes[2] = new Bicycle
("purple");
bikes[3] = new Bicycle (10,
"red");
// display initial state of all bicycles in the
array using the toString method
// Done for you
for (int i = 0; i < bikes.length; i++)
System.out.println("Bike [" + i + "]\n" + bikes[i]);
// Read in a new color and gear
for Bike[0] and
// use the set methods to change
the 'state' of bike
Scanner in = new
Scanner(System.in); // LOCAL variable
System.out.print ("Please enter the
new color of the bike[0]: ");
String color = in.nextLine();
System.out.print ("Please enter the new current
gear that the bike[0] is in: ");
int gear = in.nextInt();
// validate data
while ( (gear < 1) || (gear > 10) )
{ System.out.println (gear + " is an invalid gear
...");
System.out.print ("Valid gears are 1-10... please
re-enter: ");
gear = in.nextInt();
} // end while
System.out.println("Changing the
gear and color of bike[0]...\n");
// call setGear method on bike[0]
// call setColor method on bike[0]
// display the current state of all bicycles in the
array using the toString method
// see earlier code in this file
// Part 2 - Create another bicycle object (newBike)
that is NOT part of the array
// Color is purple and the gear is 1
// Use a loop and equals method to determine if
newBike is equal to any
// of the other bikes in the array
// If so, display "newBike object matches a current
bike in the array"
// oherwise display "newBike object does NOT match a
current bike in the array"
} //end of method main
} //end of class BicycleApp
Please find the required solution:
Bicycle.java
public class Bicycle {// instance
variables
private int gear;
private String color;
// Constructor #1: set default gear to 1 and the
color to primer gray
public Bicycle() {
gear = 1;
color = "primer gray";
} // end 'default' no-argument constructor
// Constructor #2: sets the gear to a passed-in
value
// and color to same default color as constructor
#1
public Bicycle(int newGear) {
gear = newGear;
color = "primer gray";
} // end one-argument constructor (sets the gear)
// Constructor #3: sets the color to the passed-in
value
// and the gear to the same default gear as
constructor #1
public Bicycle(String newColor) {
gear = 1;
color = newColor;
} // end one-argument constructor (sets the color)
// Constructor #4: sets the gear to the passed-in
value
// and sets the color as the passed-in value
public Bicycle(int newGear, String newColor) {
gear = newGear;
color = newColor;
} // end two-argument constructor (sets gear and
color)
// Sets the private data property 'gear' with the
value passed in
public void setGear(int newGear) {
gear = newGear;
} // end of method setGear
// Sets the private data property 'color' with the
value passed in
public void setColor(String newColor) {
color = newColor;
} // end of method setGear
/*
* // This method displays the value of the String
variable 'color' public
* void displayColor() { System.out.println("The color
of the bike is " +
* color); } // end method displayColor
*
* // This method displays the value of the int
variable 'gear' public void
* displayGear() { System.out.println("The bike is in
gear #" + gear); } //
* end method displayGear
*/
// Comment out the two methods above...
// Create a toString method that returns a String that
can
// be used to display the data properties of a bicycle
in the
// same format you are commenting out
@Override
public String toString() {
return "The color of the bike is "
+ color + " "
+ "The bike is in gear #" + gear;
}
// Create an equals method that returns true if the
bikes are
// in the same gear and are the same color, otherwise
returns false...
@Override
public boolean equals(Object arg0) {
Bicycle cycle = (Bicycle)
arg0;
return cycle.gear == gear
&& cycle.color.equals(color);
}
} // end class Bicycle
BicycleApp.java
import java.util.*;
public class BicycleApp {
public static void main(String[] args) {
Bicycle[] bikes = new
Bicycle[4];
// declare an array of 4 Bicycle
objects
// Instantiate the 4 bike objects
(Done for you)
bikes[0] = new Bicycle();
bikes[1] = new Bicycle(6);
bikes[2] = new
Bicycle("purple");
bikes[3] = new Bicycle(10,
"red");
// display initial state of all
bicycles in the array using the toString
// method
// Done for you
for (int i = 0; i <
bikes.length; i++)
System.out.println("Bike [" + i + "]\n" + bikes[i]);
// Read in a new color and gear for
Bike[0] and
// use the set methods to change
the 'state' of bike
Scanner in = new
Scanner(System.in); // LOCAL variable
System.out.print("Please enter the
new color of the bike[0]: ");
String color = in.nextLine();
System.out
.print("Please enter the new current gear that
the bike[0] is in: ");
int gear = in.nextInt();
// validate data
while ((gear < 1) || (gear >
10)) {
System.out.println(gear + " is an invalid gear ...");
System.out.print("Valid gears are 1-10... please re-enter:
");
gear =
in.nextInt();
} // end while
System.out.println("Changing the
gear and color of bike[0]...\n");
// call setGear method on
bike[0]
bikes[0].setGear(gear);
// call setColor method on
bike[0]
bikes[0].setColor(color);
// display the current state of all
bicycles in the array using the
// toString method
// see earlier code in this
file
for (int i = 0; i <
bikes.length; i++)
System.out.println("Bike [" + i + "]\n" + bikes[i]);
// Part 2 - Create another bicycle
object (newBike) that is NOT part of
// the array
Bicycle newBike = new
Bicycle();
// Color is purple and the gear is
1
newBike.setColor("purple");
newBike.setGear(1);
// Use a loop and equals method to
determine if newBike is equal to any
// of the other bikes in the
array
// If so, display "newBike object
matches a current bike in the array"
// otherwise display
// "newBike object does NOT match a
current bike in the array"
for (int i = 0; i <
bikes.length; i++) {
if
(newBike.equals(bikes[i])) {
System.out
.println("newBike object matches a current bike in the
array");
} else {
System.out
.println("newBike object does NOT match a current bike in the
array");
}
}
in.close();
} // end of method main
} // end of class BicycleApp
fisrt one is bicycle.java second code is bicycleapp.java can anyone help this??? please save my life...
Java Homework Help. Can someone please fix my code and have my program compile correctly? Thanks for the help. Specifications: The class should have an int field named monthNumber that holds the number of the month. For example, January would be 1, February would be 2, and so forth. In addition, provide the following methods. A no- arg constructor that sets the monthNumber field to 1. A constructor that accepts the number of the month as an argument. It should...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...
Please help with a source code for C++ and also need screenshot of output: Step 1: Create a Glasses class using a separate header file and implementation file. Add the following attributes. Color (string data type) Prescription (float data type) Create a default constructor that sets default attributes. Color should be set to unknown because it is not given. Prescription should be set to 0.0 because it is not given. Create a parameterized constructor that sets the attributes to the...
Please help me with this code. Thank you Implement the following Java class: Vehicle Class should contain next instance variables: Integer numberOfWheels; Double engineCapacity; Boolean isElectric, String manufacturer; Array of integers productionYears; Supply your class with: Default constructor (which sets all variables to their respective default values) Constructor which accepts all the variables All the appropriate getters and setters (you may skip comments for this methods. Also, make sure that for engineCapacity setter method you check first if the vehicle...
I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java Programming Project #4 – Classes and Objects (20 Points) You will create 3 new classes for this project, two will be chosen from the list below and one will be an entirely new class you invent.Here is the list: Shirt Shoe Wine Book Song Bicycle VideoGame Plant Car FootBall Boat Computer WebSite Movie Beer Pants TVShow MotorCycle Design First Create three (3) UML diagrams...
Please please help me with this code please Purpose: To learn the basics of linked lists You are to implement 2 classes, Scene and Movie. Note: Please dont use inbuild linkedList methods and functions The Scene class has the following fields and methods: p rivate String event private Scene nextScene Public Scene(String event) - A constructor that creates a Scene object with the event set and nextScene set to null Public Scene(String event, Scene next) - A constructor that creates...
Deliverable A zipped NetBeans project with 2 classes app ZipCode Address Classes Suggestion: Use Netbeans to copy your last lab (Lab 03) to a new project called Lab04. Close Lab03. Work on the new Lab04 project then. The Address Class Attributes int number String name String type ZipCode zip String state Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: number - 0 name - "N/A" type...
Write in java and the class need to use give in the end copy it is fine. Problem Use the Plant, Tree, Flower and Vegetable classes you have already created. Add an equals method to Plant, Tree and Flower only (see #2 below and the code at the end). The equals method in Plant will check the name. In Tree it will test name (use the parent equals), and the height. In Flower it will check name and color. In...
PLEASE READ ALL Modify the MergeSort code provided in class (if you find a mistake with it extra credit) (https://repl.it/@ashokbasawapatna/MergeSortExample) to work with Students (No need for generic types, you will only write Main.java). Then use the compareTo method for strings in Java to sort the students in Alphabetical order via MergeSort. 1) Create an array of 10 students by hand. Make sure it's not in alphabetical order. ONLY USE LOWER CASES FOR NAMES (I'll only test with that). 2)...