Question
Go to Java Online Compiler (Click it). Copy all provided code and requirements below. Finish all TODOs and test your code at the online compiler.
Go to Java Online Compiler (Click it). Copy all provided code and requirements below. Finish all TODOs and test your code at the online compiler. Do NOT modify any provided code. IMPORTANT When completed, copy all code back to the box below for submission. import java.util.*;
//A provided class representing vehicle, do NOT modify it class Vehicle { private double price; public Vehicle(double price) { this.price = price; } }
public class Main { public static void main(String[] args) { /** Expected Output: * >>Number1 = 0 * >>Number2 = 0 * >>Number3 = 3 */ System.out.println(">>Number1 = " + countCarsInModel(null, null)); System.out.println(">>Number2 = " + countCarsInModel(new ArrayList
/* ==== Do NOT modify any code above this line ==== */
/** * TODO #2: write a public static method named countCarsInModel that * - accepts two arguments, a list of vehicle and a String requiredModel * - return the number of cars of the specified model or return 0 if there is no such car * - NOTE: the given list can be null or empty; the given requiredModel can be null and is considered invalid * - NOTE: vehicles in the given list can be null or not a car * - NOTE: the model of a car can be null and is considered invalid */ }
/** * TODO #1: write a subclass of Vehicle named Car that * - has one private field named model of String type * - has an all-argument constructor that accepts a double price and a String model * - has the get and set methods for model */
// IMPORTANT: When completed, copy all code back to the text box in the quiz for submission.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started