Skip to content
← Back to Community
how do I make programs like these interactive?
Profile icon
pibinary

hello!

I'm fairly new at this and was wondering, how do I make programs like this interactive? also, is there a way to cut down on a code (like with a method or something)?

thanks!

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
pibinary
Comments
hotnewtop
Profile icon
Coder100

Before we begin, please follow conventions.
This is wrong:

image

Classes have to be upper-cased, like this:

Car toyota = new Car(...);

maybe rename your classes and files to reflect this :)

1. The easiest way is to use input

read this

2. Yes

A method would be great, define a method on the class Car, like this:

String printData() { System.out.println("its max speed is: " + getSpeed()); ... }
Profile icon
pibinary

@Coder100
wow, thanks! I'm relatively (cough, very) new at this, so I wasn't totally clear on conventions. Thanks again!

Profile icon
Coder100

np! and the conventions habits are best made early :)

@pibinary

Profile icon
pibinary

@Coder100
yeah! thanks again for the help! ;)