Question
Having trouble figuring out the code. Here's the 2 java problems. Thank you Problem 1] Define the class Car that includes the following members: Data
Having trouble figuring out the code. Here's the 2 java problems. Thank you
Problem 1] Define the class Car that includes the following members:
Data fields (properties):
o Integer data field named year which stores the year of production.
o String data field named brand to store the brand of the car.
o Integer data field named maxSpeed that stores the maximum speed of the car.
Methods:
o A no-arg constructor that sets the year property to the current year, brand to BMW, and maxSpeed to 180.
o A constructor that takes three arguments and sets the data fields accordingly.
o A void method named printCar() that displays the data fields of this object in a format of your choice.
o A method named getYear that returns the year of production of the invoking object.
o A method named getBrand that returns the brand of the invoking object.
o A method named getMaxSpeed that returns the maximum speed of the invoking object.
o A method named setYear that takes one argument and return no value. The method sets year to the taken argument.
o A method named setBrand that takes one argument and return no value. The method sets brand to the taken argument.
o A method named setMaxSpeed that takes one argument and return no value. The method sets maxSpeed to the taken argument.
Create the test class TestCar to test the class Car and sketch the UML class model of the class Car. The UML should be submitted either as an image or a word file. Northeastern Illinois University Department of Computer Science Problem 2] Define the class Quadratic that has the follow
Problem 2]
Define the class Quadratic that has the following data fields and methods.
Data fields:
o Instance data fields: a, b, and c of type double. These variables store the coefficients of a quadratic equation of the form a * x * x + b * x + c.
Methods:
o An empty no-arg constructor.
o A constructor that takes three arguments, sets the instance data fields to the taken arguments.
Quadratic(double aVal, double bVal, double cVal) { }
o A void method named setA that sets the value of the instance data field a to the value provided as an argument.
o A void method named setB that sets the value of the instance data field b to the value provided as an argument.
o A void method named setC that sets the value of the instance data field c to the value provided as an argument.
void setC(double cValue) { }
o A method that checks whether the equation has two real roots. If 2 4 0, the equation has two real roots and the method returns true, otherwise it returns false.
boolean hasRealRoots() { }
o A method that evaluates the equation at a given point x. The method returns the result of evaluating this equation at a given point x (a * x * x + b * x + c), with x given as an argument. For example, if a = 2, b = 1, and c = -1 and x = 3, the method returns 20 (2*3*3 + 1*3 -1 = 20).
double evaluateQuadratic(double x) { }
o [Extra credit: 10%] A method that returns an array of size 2 that contains the real roots of this quadratic equation. The two roots of the equation are given as follows + 24 2 and 24 2 double[] getRoots() { }
o A method that displays this object in a format of your choice. void printQuadratic() { } Create a test class named TestQuadratic to test the class Quadratic and sketch the UML class model of the Quadratic class. The UML should be submitted either as an image or a word file.
Create a test class named TestQuadratic to test the class Quadratic and sketch the UML class model of the Quadratic class. The UML should be submitted either as an image or a word file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started