Write a class Car that contains fields “make”, “model” and “year.” The first two fields are Strings and the third one is an int. Define a constructor to accept and initialize instance data. Then define more methods(see code below). A toString method is included to print the description of the car. Then create a drive class called CarTest which has a main method.  Portion of the program is given. You’ll complete the program. When you run CarTest the result should look like this

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Instruction

 

Write a class Car that contains fields “make”, “model” and “year.” The first two fields are Strings and the third one is an int. Define a constructor to accept and initialize instance data. Then define more methods(see code below). A toString method is included to print the description of the car. Then create a drive class called CarTest which has a main method.  Portion of the program is given. You’ll complete the program. When you run CarTest the result should look like this:

> run CarTest

2007 Ford Taurus

2011 Honda Odyssey

1999 Toyota Corolla

1966 Ford Mustang

 

Update data!

2007 Ford Explorer

2010 Honda Odyssey

1999 Nissan Maxima

1966 Ford Mustang

Student Here!

Hi, I've tried typing the code (The screenshots attached) but kept getting errors. Im not sure what to do so I hope that you can help me! 

Thank You!

1 package com.car;
2
3 public class CarTest
4
{
5
6
7
8
10
11
12
13
14
15
16
170
18
19
20
21
22
24
25
26
27
28
29
30
31
32
33
34
36
37
38
39
40
41
// Creates and exercises some Car objects.
private String make, model;
private int year!
public CarTest(String makeInit, String modelInit, int yearInit)
{
1
this.make-makeInit;
1
public String getMake()
{
1
this model-modelInit;
this-year-year Init;
public void setMake (String makeUpdate)
[
1
return make!
//add coda
maka-makalpdate;
public String getModel()
{
//add code
return model/
public void setModel (String modelUpdate)
{
//add code
model-modelUpdate;
☐
Transcribed Image Text:1 package com.car; 2 3 public class CarTest 4 { 5 6 7 8 10 11 12 13 14 15 16 170 18 19 20 21 22 24 25 26 27 28 29 30 31 32 33 34 36 37 38 39 40 41 // Creates and exercises some Car objects. private String make, model; private int year! public CarTest(String makeInit, String modelInit, int yearInit) { 1 this.make-makeInit; 1 public String getMake() { 1 this model-modelInit; this-year-year Init; public void setMake (String makeUpdate) [ 1 return make! //add coda maka-makalpdate; public String getModel() { //add code return model/ public void setModel (String modelUpdate) { //add code model-modelUpdate; ☐
43
46
47
48
49
50
51
52
53
54
56
57
59
61
6.2
63
64
6.5
66-
67
-X68
-X69
-x70
x71
72
73
74
75
76
77
78
79
80
81
82
1
1
public int getYear()
{
1
//add code
return year;
public void setYear (int yearUpdate)
{
year yearUpdate;
1
{
Returns a string representation of this Car.
public String toString()
{
//add code
return toString();
public static void main(String[] args)
CarTest el - newCarTest("Ford", "Tarus", 2007);
CarTest c2 - newCarTest("Honda", "Odessey", 2011);
CarTest c3 = newCarTest("Toyota","Corrolla", 1999);
CarTest c4 - newCarTest("Ford", "Mustang", 1966);
/*add code here. Hint: Call constructor four times to create four objects. Then print the descriptions of the
System.out.println(el);
System.out.println (c2);
System.out.println (c3);
System.out.println(c4);
/*add code here. Hint: Update data and print updated information.*/
Transcribed Image Text:43 46 47 48 49 50 51 52 53 54 56 57 59 61 6.2 63 64 6.5 66- 67 -X68 -X69 -x70 x71 72 73 74 75 76 77 78 79 80 81 82 1 1 public int getYear() { 1 //add code return year; public void setYear (int yearUpdate) { year yearUpdate; 1 { Returns a string representation of this Car. public String toString() { //add code return toString(); public static void main(String[] args) CarTest el - newCarTest("Ford", "Tarus", 2007); CarTest c2 - newCarTest("Honda", "Odessey", 2011); CarTest c3 = newCarTest("Toyota","Corrolla", 1999); CarTest c4 - newCarTest("Ford", "Mustang", 1966); /*add code here. Hint: Call constructor four times to create four objects. Then print the descriptions of the System.out.println(el); System.out.println (c2); System.out.println (c3); System.out.println(c4); /*add code here. Hint: Update data and print updated information.*/
Expert Solution
Step 1

Refer below the correct version of your given code with output:

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education