Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Vehicle/src/VehicleNoise.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import model.Example;
import model.Car;
import model.Train;
import model.Motorcycle

public class VehicleNoise {

Expand All @@ -23,6 +24,10 @@ public static void main(String[] args) {
// my vehicle noise
Car Mustang = new Car();
System.out.println(Mustang.makeNoise());

// Motorcycle
Motorcycle motorcycle = new Motorcycle();
System.out.println(motorcycle.makeNoise());

}

Expand Down
112 changes: 112 additions & 0 deletions Vehicle/src/model/Motorcycle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package model;

/**
* Represents a Motorcycle with properties such as year, make, and model.
* This class provides methods to get and set these properties, as well as
* methods for generating noise and obtaining a string representation of the motorcycle.
*
* @author Corbin Goodman - cgoodman4
* CIS175 - Fall 2023
* Aug 29, 2023
*/
public class Motorcycle {

// Fields representing the properties of the motorcycle
private int year; // The year of the motorcycle
private String make; // The make (brand) of the motorcycle
private String model; // The model name of the motorcycle

/**
* Default constructor to create an empty Motorcycle object.
*/
public Motorcycle() {
super();
}

/**
* Constructs a Motorcycle object with the provided year, make, and model.
*
* @param year The year of the motorcycle
* @param make The make (brand) of the motorcycle
* @param model The model name of the motorcycle
*/
public Motorcycle(int year, String make, String model) {
super();
this.year = year;
this.make = make;
this.model = model;
}

/**
* Get the year of the motorcycle.
*
* @return The year of the motorcycle
*/
public int getYear() {
return year;
}

/**
* Set the year of the motorcycle.
*
* @param year The year of the motorcycle
*/
public void setYear(int year) {
this.year = year;
}

/**
* Get the make (brand) of the motorcycle.
*
* @return The make of the motorcycle
*/
public String getMake() {
return make;
}

/**
* Set the make (brand) of the motorcycle.
*
* @param make The make of the motorcycle
*/
public void setMake(String make) {
this.make = make;
}

/**
* Get the model name of the motorcycle.
*
* @return The model name of the motorcycle
*/
public String getModel() {
return model;
}

/**
* Set the model name of the motorcycle.
*
* @param model The model name of the motorcycle
*/
public void setModel(String model) {
this.model = model;
}

/**
* Generate a string representation of the motorcycle.
*
* @return A formatted string describing the motorcycle
*/
@Override
public String toString() {
return String.format("This motorcycle is a %d %s %s", this.year, this.make, this.model);
}

/**
* Generate the sound of the motorcycle engine.
*
* @return The sound of the motorcycle engine
*/
public String makeNoise() {
return "vroom vroom";
}
}