y program is not running in my eclipse, can you let me know how runs and if they're any errors. Also, is my input of my Vehicle program put in correctly ( public static void Vehicle(String[] args) {) The instructions are:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

My program is not running in my eclipse, can you let me know how runs and if they're any errors. Also, is my input of my Vehicle program put in correctly ( public static void Vehicle(String[] args) {)

The instructions are: 

Design and save your Motor class before you make Vehicle, so you can specify Motor as a Vehicle data attribute.

Class Motor (make this class first because Motor is an attribute of class Vehicle)
Attributes (all private)

  • int cylinders
  • int hp
  • String type (possible values being gasdeiselelectric etc)

Methods (all public)

  • constructor that can assign values to all attributes
  • getters and for each attribute (setters not needed)
  • toString method that returns the status of a Motor instance, all attributes.

Class Vehicle
Attributes (all private)

  • String make
  • String model
  • int year
  • double price
  • Motor motor (see below)

Methods (public)

  • a constructor that can assign values to all attributes
  • a setter for the price
  • a getter for the price
  • a toString method that returns the status of a Vehicle instance, all attributes.

Class TestVehicle
This is the executable class. In the main method, make an arraylist of five or six Vehicle instances and then use a foreach loop to display them.

Motor:

private int cylinders;
        private int hp;
        private String type;
        
        public Motor (int cylinders, int hp, String type) {
            this.cylinders = cylinders;
            this.hp = hp;
            this.type = type;
    }
        public int getCylinders() {
            return cylinders;
        }
        public int getHp() {
            return hp;
        }
        public String getType() {
            return type;
        }
        @Override
        public String toString() {
            return "Motor (" + "Cylinders: " + cylinders + "HP: " + hp + "Type: " + type + ')';
        }

}

 

Vehicle:

private String make;
    private String model;
    private int year;
    private double price;
    private Motor motor;
    
    public Vehicle (String make, String model, int year, double price, Motor motor) {
        this.make = make;
        this.model = model;
        this.year = year;
        this.price = price;
        this.motor = motor;
    }
    
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    
    @Override
    public String toString() {
        return "Vehicle: " + "Make = " + make + "Model = " + model + "Year = " + year + "Price = " + price + "Motor = " + motor;
    }
}

 

TestVehicle:

import java.util.ArrayList;

class TestVehicle { 
//PSEUDOCODE
    //This is the executable class
    // In the main method, make an arraylist of five or six Vehicle instances and then use a foreach loop to display them
    
    public static void Vehicle(String[] args) {
        ArrayList<Vehicle> vehicleType = new ArrayList<Vehicle>();
            
        vehicleType.add(new Vehicle ("Nissan", "GT-R", 2018, 80000.0, new Motor(6, 565, "Gasoline Fuel")));
        vehicleType.add(new Vehicle ("Nissan", "350z", 2009, 14279.0, new Motor(6, 306, "Gasoline Fuel")));
        vehicleType.add(new Vehicle ("Nissan", "370z", 2018, 43349.0, new Motor(6, 332, "Gasoline Fuel")));
        vehicleType.add(new Vehicle ("Nissan", "Z", 2023, 42990.0, new Motor(6, 400, "Electric or Gasoline Fuel")));
        vehicleType.add(new Vehicle ("Lamborghini", "Aventador S", 2018, 418000.0, new Motor(12, 691, "Gasoline Fuel")));
        vehicleType.add(new Vehicle ("Chevrolet", "Camaro", 2022, 43845.0, new Motor(8, 650, "Gasoline Fuel")));
        
        for (Vehicle eachVeh: vehicleType) {
            System.out.println(eachVeh.toString());
        }
    }

}

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to Template
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY