subject

Create a UsedCarException class that extends Exception; its constructor receives a value for a vehicle identification number (VIN) that is passed to the parent constructor so it can be used in a getMessage() call. Create a UsedCar class with fields for VIN, make, year, mileage, and price. The UsedCar constructor throws a UsedCarException when the VIN is not four digits; when the make is not Ford, Honda, Toyota, Chrysler, or Other; when the year is not between 1997 and 2017 inclusive; or either the mileage or price is negative. Write an application that establishes an array of at least seven UsedCar objects and handles any Exceptions. Display a list of only the UsedCar objects that were constructed successfully. 1.
public class ThrowUsedCarException {
public static void main(String[] args) {
// Write your code here
}
}
2.
import java. util.*;
public class UsedCar {
String vin;
String make;
int year;
int mileage;
int price;
public final static String DEFAULT_VIN = "999";
final int VIN_NUM_LENGTH = 4;
final int LOW_YEAR = 1997;
final int HIGH_YEAR = 2017;
final String[] MAKES = {"Ford", "Honda", "Toyota", "Chrysler", "Other"};
public UsedCar(String num, String carMake,
int carYear, int miles, int pr) throws UsedCarException {
}
public UsedCar() {
}
public String getVin() {
}
public String toString() {
return "VIN " + vin + " Make: " + make +
"\n Year: " + year + " " + mileage + " miles $" +
price;
}
}
3.
public class UsedCarException extends Exception {
public UsedCarException(String s) {
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:10, ianmartin6080
Assume that minutes is an int variable whose value is 0 or positive. write an expression whose value is "undercooked" or "soft-boiled" or "medium-boiled" or "hard-boiled" or "overcooked" based on the value of minutes. in particular: if the value of minutes is less than 2 the expression's value is "undercooked"; 2-4 would be a "soft-boiled", 5-7 would be "medium-boiled", 8-11 would be "hard-boiled" and 12 or more would be a "overcooked".
Answers: 1
image
Computers and Technology, 24.06.2019 14:00, ameliaxbowen7
Which computer tools allow you to communicate with coworkers, family, and friends
Answers: 1
image
Computers and Technology, 24.06.2019 17:30, NEONREDBLADE
Match the following. 1. formatting that is applied when cell data meets certain criteria 2. borders with formats not found on the border tool 3. a shortcut bar that contains tools for commonly used formats 4. formats that can be applied to numbers conditional formatting custom borders format bar number formats
Answers: 3
image
Computers and Technology, 24.06.2019 17:40, finedock
Anewly established internet company with 40 employees needs your advice. they are looking for a collaboration tool and have narrowed their choices to gotomeeting, webex, and my web conferences. after reading the information presented in this chapter and other sources, prepare a two- page document ( double spaced) that includes two advantages and two disadvantages of each tool. which one is your final recommendation? why did you choose that tool over the other two?
Answers: 3
You know the right answer?
Create a UsedCarException class that extends Exception; its constructor receives a value for a vehic...

Questions in other subjects: