Program.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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Program.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 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.

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:

A lower case character, two upper case characters, two or three digits, two lower case characters, an upper case character, 2 or 3 lower case characters, 2 digits.

Refer to Appendix H beginning on pages 1176
.
Example Run

Enter the code pattern
bHT482haQmo82
Yes, bHT482haQmo82 matches the pattern

Recheck the requirements before you submit!

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT