Create an Interface Car. You will need the following methods in this interface :
ID: 3599791 • Letter: C
Question
Create an Interface Car. You will need the following methods in this interface :
getNumberOfTyres, getMaxSpeed(), getNumberOfDoors();, getNumberOfLights();
Now create a concrete Car Honda that implements this interface and return appropriate values.
After creating Honda create another class CivicSport that extends Honda and implements Car and add the following methods to it :
boolean hasGPS() {returns true;};
override getNumberOfDoors and return 2 as this is a sports car.
Finally write a class with a main method that prints out all the information about the CivicSport.
Explanation / Answer
package com;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JPanel;
public class Graph extends JPanel {
public Graph() {
setSize(500, 500);
}
@Override
public void paintComponent(Graphics g) {
Graphics2D gr = (Graphics2D) g; // This is if you want to use Graphics2D
// Now do the drawing here
ArrayList<Integer> scores = new ArrayList<Integer>(10);
Random r = new Random();
for (int i : scores) {
i = r.nextInt(20);
System.out.println(r);
}
int y1;
int y2;
for (int i = 0; i < scores.size() - 1; i++) {
y1 = (scores.get(i)) * 10;
y2 = (scores.get(i + 1)) * 10;
gr.drawLine(i * 10, y1, (i + 1) * 10, y2);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.