Ask coding questions

← Back to all posts
how do I make programs like these interactive?
pibinary (1)

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 (16809) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (16809)

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

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());
  ...
}
pibinary (1)

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

Coder100 (16809)

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

pibinary (1)

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