To instantiate any class, we need to ahve constructors. As the question asked, there are 3 mandatory fileds and 4 optional fields for ParkingPermit. and we can not use setters and getters. So the only way we can give values to these fileds is by constructors. So we will instatiate this class by using overloaded constructors. We will have diffrent constructors with diffrent fields. All constructors have three mandatory fileds plus the optional fields. we can use any one of them to instantiate the class and set the values in required fields. Any field that is not given value through constructor parametrs will be set "Not Defined". I have provided 4 constructors or in other words 4 diffrent ways to instantiate the class. below is the class code with all 4 constructors.
public class ParkingPermit {
String make;
String model;
String LicencePlate;
String year;
String VIN;
String color;
String Owner;
//Constructor with all parameters
//instantiate by giving all the parameters
public ParkingPermit(String make, String model, String licencePlate, String year, String vIN, String color,
String owner) {
this.make = make;
this.model = model;
LicencePlate = licencePlate;
this.year = year;
VIN = vIN;
this.color = color;
Owner = owner;
}
//constructor with 4 parametrs, 3 mandatory and 1 optional
//instantiate object by giving 4 parameters
public ParkingPermit(String make, String model, String licencePlate, String owner) {
this.make = make;
this.model = model;
LicencePlate = licencePlate;
Owner = owner;
//setting parameters which are not given in constructor
color="Not Defined";
year="Not Defined";
VIN="Not Defined";
}
//constructor with 5 parametrs, 3 mandatory and 2 optional
//instantiate class by giving 5 parameters
public ParkingPermit(String make, String model, String licencePlate, String color, String owner) {
this.make = make;
this.model = model;
LicencePlate = licencePlate;
this.color = color;
Owner = owner;
//setting parameters which are not given in constructor
year="Not Defined";
VIN="Not Defined";
}
//constructor with 6 parametrs, 3 mandatory and 3 optional
//instantiate class by giving 6 parameters
public ParkingPermit(String make, String model, String licencePlate, String color, String year, String owner) {
this.make = make;
this.model = model;
LicencePlate = licencePlate;
this.color = color;
this.year = year;
Owner = owner;
//setting parameters which are not given in constructor
VIN="Not Defined";
}
}
class Parking Permit has seven fields, but only of three of them are required for issuing...
Language is JAVA.
Clarification for the Shape class (highlighted):
The following requirements specify what fields you are expected
to implement in your Shape class;
- A private String color that specifies the color of the
shape
- A private boolean filled that specifies whether the shape is
filled
- A private date (java.util.date) field dateCreated that
specifies the date the shape was created Your Shape class will
provide the following constructors;
- A two-arg constructor that creates a shape
with...
Please help me with this exercises in JAVA, Thank you ===================== Parking Ticket Simulator Assignment ===================== For this assignment you will create a set of classes from scratch (no provided class files for this assignment) that work together to simulate a police officer issuing a parking ticket. You should design the following classes / functionality within them: ===================== ParkedCar.java: ===================== This class should simulate a parked car. The class's responsibilities are as follows: - To store the car's make, model,...
Car class Question Design a class named car that has the following fields: YearModel: The yearModel field is an integer that holds the car's year model. Make: The make field references a string that holds the make of the car. Speed: The speed field is an integer that holds the car's current speed. In addition, the class should have the following constructor and other methods: Constructor: The constructor should accept the. car's year model and make as arguments. The values...
Java Program Write a class named Car that has the following fields: yearModel- The yearModel field is an int that holds the car’s year model. make- The make field is a String object that holds the make of the car, such as “Ford”, “Chevrolet”, etc. speed- This speed field is an int that holds the car’s current speed. In addition, the class should have the following methods: Constructor- The constructor should accept the car’s year model and make as arguments....
Assignment Requirements
I have also attached a Class Diagram that describes the
hierarchy of the inheritance and interface behaviors . The link to
the PDF of the diagram is below
MotorVehical.pdf
Minimize File Preview
User Define Object Assignment:
Create a Intellij Project. The
Intellij project will contain three user defined
classes. The project will test two of the User Define Classes by
using the invoking each of their methods and printing the
results.
You are required to create three UML...
In java How to get started; Create a class called Card. The card has three fields; a value , a suit and a face. The card class has a constructor that takes three values for the three fields. Create a no-args constructor. The Card class has three get methods to return the values of each of the fields. The Card class has a toString( ) method. The Card class has a compareTo( ) method that uses the value of the...
I need help with this java project and please follow the instruction below. thank Class Project - Parking Ticket simulator Design a set of classes that work together to simulate a police officer issuing a parking ticket. Design the following classes: • The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are as follows: – To know the car’s make, model, color, license number, and the number of minutes that the car has been parked. • ...
signature 1. Create a new NetBeans Java project. The name of the project has to be the first part of the name you write on the test sheet. The name of the package has to be testo You can chose a name for the Main class. (2p) 2. Create a new class named Address in the test Two package. This class has the following attributes: city: String-the name of the city zip: int - the ZIP code of the city...
This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...
*** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J IN CLASS (IF IT DOESNT MATTER PLEASE COMMENT TELLING WHICH PROGRAM YOU USED TO WRITE THE CODE, PREFERRED IS BLUE J!!)*** ArrayList of Objects and Input File Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList<Car> list . Program should work for input file containing info...