import javax.swing.*;
import java.awt.*;
class Carz extends JFrame {
Carz() {
super("Cars");
setSize(1000,1000);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
Car Ferrari = new Car(20, 200, "Red");
Car Lexus = new Car(30, 160, "White");
Car Honda = new Car(25, 150, "Blue");
public void paint(Graphics m) {
m.setFont(new Font( "Helvetica", Font.PLAIN, 16));
m.drawRect(20, 50, 960, 460);
m.setColor(Color.BLACK);
m.fillRect(20, 50, 960, 460);
m.setColor(Color.WHITE);
m.drawString("We have a " + Ferrari.color + "that gets " + Ferrari.mpg + "and can go as fast as " + Ferrari.mph + ".", 30,70);
m.drawString("We have a " + Honda.color + "that gets " + Honda.mpg + "and can go as fast as " + Honda.mph + ".", 30,100);
m.drawString("We have a " + Lexus.color + "that gets " + Lexus.mpg + "and can go as fast as " + Lexus.mph + ".", 30,130);
}
public static void main(String[] args) {
new Carz();
}
}
class Car{
int mpg;
int mph;
String color;
Car(int mpg, int mph, String color){
this.mpg = mpg;
this.mph = mph;
this.color = color;
}
}