Purchase Solution

Auto Java Class

Not what you're looking for?

Ask Custom Question

public class Auto{
public int miles;
public int gas;
}
1. Encapsulate this class ( set vars to private.) Provide getmethods and setmethods for each variable
2. Add a default constructor which initializes miles and gas to zero
3. Overload this constructor which takes 2 parameters: inputmiles and inputgas.
This constructor then sets the class variables miles and gas to the respective input parameters, inputmiles and inputgas.

Purchase this Solution

Solution Summary

Error free java code is provided for the given problem.

Solution Preview

Hi,

Kindly see the code below or run the attached auto.java file in Netbeans or any other java editor.

Feel free to modify it as per your requirements as well. I have used int data type, you can change it with float to accept floating points.

best, ...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Networking Questions

This quiz consists of some basic networking questions.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Javscript Basics

Quiz on basics of javascript programming language.