Java Session-Vehicle
Java Session-Vehicle
Write getters, setters and parameterized constructor in the above mentioned attribute
sequence as required.
FindVehicleWithMinimumPrice
SearchVehicleByName
Create a static method searchVehicleByName in the Solution class. This method will take
array of Vehicle objects and Name as input and returns the Vehicle object having the
mentioned Name if found else return null if not found.
Sample Output 1
number-3111
name-bus
price-1000.0
number-6115
name-Scooter
price-2700.0
Sample Output 2
number-1109
name-Train
price-2000.0
number-4112
name-bike
price-5600.0
Solution:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
// calling methods
Vehicle an1=findVehicleWithMinimumPrice(v);
Vehicle an2=searchVehicleByName(v, sn);
//printing methods
if(an1==null){
System.out.println("No Vehicle found with mentioned attribute");
}
else{
System.out.println("number-"+an1.getNum());
System.out.println("name-"+an1.getName());
System.out.println("price-"+an1.getPrice());
}
//2nd method printing
if(an2==null){
System.out.println("No Vehicle found with mentioned attribute");
}
else{
System.out.println("number-"+an2.getNum());
System.out.println("name-"+an2.getName());
System.out.println("price-"+an2.getPrice());
//main close
}
public static Vehicle findVehicleWithMinimumPrice(Vehicle[] v){
}//class closes
class Vehicle {
}
// extra brace- enum expected
//class }using incorrectly-- static and non static
// one less- reached end of file while parsing
// close main
//null pointer
//array out of bounds
//partial test cases