1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lubov Fominskaja [6]
3 years ago
15

Write a class called Car that contains instance data that represents the make, model, and year of the car. Define the Car constr

uctor to initialize these values. Include getter and setter methods for all instance data, and a toString method that returns a one-line description of the car. Add a method called isAntique that returns a Boolean indicating if the car is an antique (if it is more than 45 years old). Create a driver class called CarTest, whose main method instantiates and updates several Car objects.
Computers and Technology
1 answer:
liq [111]3 years ago
5 0

Answer:

Java Code example

Explanation:

Java Code

import java.util.Calendar;

public class CarTest {

   public static void main(String [] args){

       Car car1 = new Car("Honda","Civic", 2015);

       System.out.println(car1.toString());

       System.out.println("Car 1 is antique : "+car1.isAntique());

       Car car2 = new Car("Toyota","A", 1945);

       System.out.println(car2.toString());

       System.out.println("Car 2 is antique : "+car2.isAntique());

       Car car3 = new Car("Lamborghini","Model A", 2019);

       System.out.println(car3.toString());

       System.out.println("Car 3 is antique : "+car3.isAntique());

   }

}

class Car{

   private String model;

   private String  make;

   private int year;

   public Car( String make,String model, int year) {

       this.model = model;

       this.make = make;

       this.year = year;

   }

   public String getModel() {

       return model;

   }

   public void setModel(String model) {

       this.model = model;

   }

   public String getMake() {

       return make;

   }

   public void setMake(String make) {

       this.make = make;

   }

   public int getYear() {

       return year;

   }

   public void setYear(int year) {

       this.year = year;

   }

   public boolean isAntique(){

       return Calendar.getInstance().get(Calendar.YEAR)-year>45;

   }

   @Override

   public String toString() {

       return "Car{" +

               "model='" + model + '\'' +

               ", make='" + make + '\'' +

               ", year=" + year +

               '}';

   }

}

Code Explanation

Declaring the instance variable and initializing those in constructor. Defining there getter setter and create a toString method, toString method will return the overall object representation.

To check whether car is antique or not, we will use java.util.Calendar class, This class will return the current date year from which we can compare the car year to check whether the car is antique or not.

Output

Output of above TestCar is given below.

__________________________________

Car{model='Civic', make='Honda', year=2015}

Car 1 is antique : false

Car{model='A', make='Toyota', year=1945}

Car 2 is antique : true

Car{model='Model A', make='Lamborghini', year=2019}

Car 3 is antique : false

You might be interested in
Soo...My Old 3DS XL haven't been touched in around a year...So i tried to charge it but no LED lights opened..Even the power but
Firlakuza [10]

Try charging overnight, otherwise it is most likely broken. Hope you get a new 3DS, although the Nintendo Switch is also a great console to consider!

5 0
3 years ago
What term refers to a device or software system that collects environmental information and makes independent decisions.
blondinia [14]

Answer: Environment sensing Collector

Explanation:

An environmental monitoring system or collectors is the process which a device uses in monitoring the quality of the environment. These devices or software allows for a realtime monitoring and checking of any parameter required. They are used to monitor and collect data on environmental conditions such as relative humidity, temperature, dew and frost point, differential pressure, pressure, flow, and many more.

6 0
3 years ago
Describe how communication strengthens relationship at work and, as a result, increases your productivity
olganol [36]

Answer:

because it helps them understand their contributions and obligations towards the organisation.

Explanation:

In an organizational setup, the need for healthy and effective communication among employees and employers is a crucial element for the overall success of the organisation. Healthy and effective communication helps in the productivity of the employees because it helps them understand their contributions and obligations towards the organisation.

Good communication improves the employees' morality and sincerity as it helps them feel responsible and as an important member of the organisation. Hence, strengthening their relationships and, as a result, increasing their productivity and efficiency.

7 0
3 years ago
3.8 LAB: Read values into a list
Salsk061 [2.6K]

An example of Read values into a list is:

#!/usr/bin/python

list1 = ['math', 'chemistry', 1995, 2001];

list2 = [1, 2, 3, 4, 5, 6, 7 ];

print "list1[0]: ", list1[0]

print "list2[1:5]: ", list2[1:5]

<h3>What is Python Lists?</h3>

This is known to be a list that is seen as the a most versatile in terms of datatype that are known to be available in Python.

It is one that can be written as a list of comma-separated values that is found in between square brackets.

Note that the most Important thing about a list is that all the items in a list are ones that do not require to be of the same type.

Hence Creating a list is very simple to do and it is done by putting a lot of comma-separated values in between square brackets.

Therefore, An example of Read values into a list is:

#!/usr/bin/python

list1 = ['math', 'chemistry', 1995, 2001];

list2 = [1, 2, 3, 4, 5, 6, 7 ];

print "list1[0]: ", list1[0]

print "list2[1:5]: ", list2[1:5]

Learn more about python list  from

brainly.com/question/24232863

#SPJ1

8 0
1 year ago
How do you find a single number or name you want in a
Tamiku [17]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

You can find a single number or name in a large worksheet containing thousands of numbers and names using the find and replacement feature in excel.

You can use Ctrl+F keyboard shortcut for finding and replacing features. When you press Ctrl+F, a dialog will get open, using this dialog, you can find the required number or name while entering in the search text box. Then, click on the Find button, if the worksheet matches the result, give you the matched result in the yellow highlighted color.

Also, you can use Ctrl+F to replace a name or number with some other name or number.

Alternatively, you can do this using the home tab, then find the option find and select under the editing group of commands.

8 0
3 years ago
Other questions:
  • Somebody who is good at this stuff, please halp meh ;-;
    6·1 answer
  • Approximately what percent of desktop PCs are used for work-related purposes?
    13·2 answers
  • How can you add contrast between text and headlines in a document? increase the font size of the headline make the headline long
    6·1 answer
  • William found out that someone used his report on American culture without his permission. What is William a victim of? A. plagi
    7·2 answers
  • Which of the following is true of horror films like Insidious and The Conjuring?
    15·2 answers
  • 4. UPS stands for Uninterrupted Power Supply . (Yes /no
    11·1 answer
  • Plz subscribe my yt gaming channel <br>FIREAZZ GAMING​
    8·2 answers
  • How many operations can a computer perform every second?
    13·1 answer
  • What are logic gates ?​
    10·2 answers
  • What are 3 of the most important things about internet safety that you would recommend and why
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!