Question

I am designing a project related to online parking system. ParkingSystem is a class and Driver...

I am designing a project related to online parking system. ParkingSystem is a class and Driver is another class. The parking system uses database to fetch the data related to available parking spots. To fetch the parking spots and the distance from drivers location to the parking spot, I need to specify the users current location . I am unable to understand how to code in Java to send the users current location. I have these as my fields in Driver class. How do i add method or is there any import location to send the users location?

public class Driver {

private String custName;

private String LicensePlate;

private int custId;

private int phoneNumber;

private String carMake;

private String carModel;

private int carYear;

private int currentReservation;

public Driver location;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ParkingSystem locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, new LocationListener() {

@Override

public void Driver {

@Override

public void custName(String s, int i, Bundle bundle) {}

@Override

public void onProviderEnabled(String s) {}

@Override

public void onProviderDisabled(String s) {}

@Override

public void onLicensePlate (int i) {}

@Override

public void oncustId (int i) {}

@Override

public void onphoneNumber (int i) {}

@Override

public void oncarMake (String s) {}

@Override

public void oncarModel (String s) {}

@Override

public void oncarYear (int i) {}

@Override

public void oncurrentReservation(int i) {}

@Override

public void onDriverLocation(final Location location) {}

});

ParkingSystem myLocation = locationManager.getCurrentLocation(LocationManager.PASSIVE_PROVIDER);

double longitude = myLocation.getLongitude();

double latitude = myLocation.getLatitude();

message+="https://www.google.co.id/maps/@"+latitude+","+longitude;

Add a comment
Know the answer?
Add Answer to:
I am designing a project related to online parking system. ParkingSystem is a class and Driver...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java. Java is a new programming language I am learning, and so far I am a...

    Java. Java is a new programming language I am learning, and so far I am a bit troubled about it. Hopefully, I can explain it right. For my assignment, we have to create a class called Student with three private attributes of Name (String), Grade (int), and CName(String). In the driver class, I am suppose to have a total of 3 objects of type Student. Also, the user have to input the data. My problem is that I can get...

  • How to build Java test class? I am supposed to create both a recipe class, and...

    How to build Java test class? I am supposed to create both a recipe class, and then a class tester to test the recipe class. Below is what I have for the recipe class, but I have no idea what/or how I am supposed to go about creating the test class. Am I supposed to somehow call the recipe class within the test class? if so, how? Thanks in advance! This is my recipe class: package steppingstone5_recipe; /** * *...

  • Hey guys I am having trouble getting my table to work with a java GUI if...

    Hey guys I am having trouble getting my table to work with a java GUI if anything can take a look at my code and see where I am going wrong with lines 38-49 it would be greatly appreciated! Under the JTableSortingDemo class is where I am having erorrs in my code! Thanks! :) import java.awt.*; import java.awt.event.*; import java.util.*; import java.util.List; import javax.swing.*; public class JTableSortingDemo extends JFrame{ private JTable table; public JTableSortingDemo(){ super("This is basic sample for your...

  • Hi so I am currently working on a project for a java class and I am...

    Hi so I am currently working on a project for a java class and I am having trouble with a unit testing portion of the lab. This portion wants us to add three additional tests for three valid arguments and one test for an invalid argument. I tried coding it by myself but I am not well versed in unit testing so I am not sure if it is correct or if the invalid unit test will provide the desired...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

  • Hey I am having trouble with this problem in C++: The first race is tomorrow! You...

    Hey I am having trouble with this problem in C++: The first race is tomorrow! You are provided a list of race entries in the following form: vector<string> entryList = { "42, Vance Cardoza", "55, Vanessa Pandara", "36, Gaston Carlton", "99, Rich Diesel", "10, Euler Bustamente" }; In your main() function instantiate a Race object. Use a C++ iterator to walk through the entries in the list above, parse out each car number and driver name and add them to...

  • I am currently using eclipse to write in java. A snapshot of the output would be...

    I am currently using eclipse to write in java. A snapshot of the output would be greatly appreciated to verify that the program is indeed working. Thanks in advance for both your time and effort. Here is the previous exercise code: /////////////////////////////////////////////////////Main /******************************************* * Week 5 lab - exercise 1 and exercise 2: * * ArrayList class with search algorithms * ********************************************/ import java.util.*; /** * Class to test sequential search, sorted search, and binary search algorithms * implemented in...

  • C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employee...

    C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employees to be compared by the Name, Age, and Pay, respectively. Code: Employee.Core.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Employees { partial class Employee { // Field data. private string empName; private int empID; private float currPay; private int empAge; private string empSSN = ""; private string empBene...

  • I am working on integrating a database to an Android application for a course. Currently, I have all the database code done, but getting all of the EditText fields to enter data into the database has...

    I am working on integrating a database to an Android application for a course. Currently, I have all the database code done, but getting all of the EditText fields to enter data into the database has me stuck. Assignment objectives here, so we can be on the same page: Create a second page with a data entry form and the following fields: recipename, category, ingredients, and instructions. Make the Category field a dropdown box that contains the recipe categories listed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT