Question: In Java Part 1: requires three files: Design and save your Motor class before you make Vehicle , so you can specify Motor as a
In Java
Part 1: requires three files: 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 gas, deisel, electric etc)
Methods (all public)
- a constructor that can assign values to all attributes
- getters and for each attribute (setters not needed)
- a 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. Part 2
1. Write a Java program that prompts the user to enter a security code that matches a specific pattern. Your program must approve the user's entry. The pattern consists of these characters in this sequence: An upper case character, a lower case character, an upper case character, a lower case character, any 4 digits, 2 or 3 lower case letters, 2 upper case characters, 1 digit. Refer to Appendix H beginning on pages 1170. Example Run
Enter the code pattern AbCd1234abcXX0 Yes, AbCd1234abcXX0 matches the pattern
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
