5.02 Java Example Gasoline detection

Source: Internet
Author: User

Package Woxihuan; Public classCar {//oil Monitoring system for automobiles//define a class of car//Car: Brand, average fuel consumption, mailbox capacity//What brand of car drove how many kilometers, consumption of gasoline how much L, Mailbox left how much l//Get         PublicCar (String _name, Double _sal,int_volume, Double _distance) {Name=_name; Sal=_sal; Volume=_volume; Distance=_distance; Operation= Sal *distance; Operation1= Volume-operation; }        //Set         PublicCar () {name="Audi"; Sal=13.5; Volume= -; Distance=1.5; Operation= Sal *distance; Operation1= Volume-operation; }                PrivateString name;//Brand        Private DoubleSal//Fuel Consumption        Private intVolume//capacity        Private DoubleDistance//How many kilometres did you drive?        Private DoubleOperation;//operation consumption of gasoline        Private DoubleOperation1;//How much is left in the arithmetic tank?                 Public voidresult () {System. out. println (name +"it's moving."+ Distance +"km, petrol consumption:"+ Operation +"L, the tank is still left:"+ Operation1 +"L. " ); }                 PublicString GetName () {returnname; }         Public voidsetName (String name) { This. Name =name; }}
Package Woxihuan; Public classChe { Public Static voidMain (string[] args) {//GetCar e =NewCar ("Audi A3",8.2, -,2.6);                E.result (); //SetCar e2 =NewCar (); E2.setname ("Audi R8");                            E2.result (); }}

5.02 Java Example Gasoline detection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.