Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Parked Simulator HELP PLEASE!

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Parked Simulator HELP PLEASE!

    I am having trouble with my Police Officer class, it says its incompatible types. What does that mean? Help Please




    public class ParkedCar {

    private String make;
    private String model;
    private String color;
    private String license;
    private static int minutes;

    public ParkedCar() {

    }

    public ParkedCar(String carMake, String carModel, String carColor, String carLicense, int carMinutes) {

    make = carMake;
    model = carModel;
    color = carColor;
    license = carLicense;
    minutes = carMinutes;
    }

    public String getMake() {
    return make;
    }
    public String getModel() {
    return model;
    }
    public String getColor() {
    return color;
    }
    public String getLicense() {
    return license;
    }
    public static int getMinutes() {
    return minutes;
    }

    public String toString() {

    String string = "Make: " + make
    + "\nModel: " + model
    + "\nColor: " + color
    + "\nLicense Plate: " + license;
    return string;

    }


    }

    ___________________


    public class ParkingMeter

    {

    private static int minPurchased;

    public ParkingMeter() {

    }

    public ParkingMeter(int carMinPurchased) {

    minPurchased = carMinPurchased;
    }

    public static int getMinPurchased() {
    return minPurchased;
    }

    public String toString() {
    String string = "Minutes Purchased: " + minPurchased;
    return string;
    }
    }

    ____________________

    public class ParkingTicket {

    private ParkedCar vehicle;
    private PoliceOfficer policeofficer;
    private double fine;
    private int minutes;
    private double firstFine = 25;
    private double moreFine = 10;

    public ParkingTicket(ParkedCar car, PoliceOfficer cop, double guyFine, int mins) {

    vehicle = car;
    policeofficer = cop;
    fine = guyFine;
    minutes = mins;
    }

    public void getTotalFine() {
    int time = ParkedCar.getMinutes() - ParkingMeter.getMinPurchased();

    if(time <= 60) {
    fine = firstFine;
    }
    else {
    fine = firstFine + moreFine * (time / 60);
    }
    }

    public double getFirstFine() {
    return firstFine;
    }
    public double getMoreFine() {
    return moreFine;
    }
    public ParkedCar getVehicle() {
    return vehicle;
    }
    public PoliceOfficer getpoliceofficer() {
    return policeofficer;
    }
    public int getMinutes() {
    return minutes;
    }
    public double getFine() {
    return fine;
    }


    }

    _____________

    public class PoliceOfficer {

    private String name;
    private int badge;
    private static double ticket;

    public PoliceOfficer() {

    }

    public PoliceOfficer(String poName, int poBadge) {

    name = poName;
    badge = poBadge;
    }

    public String getName() {
    return name;
    }
    public int getBadge() {
    return badge;
    }

    static ParkingTicket search(ParkedCar car, ParkingMeter meter) {

    int time = ParkedCar.getMinutes() - ParkingMeter.getMinPurchased();

    if(ParkedCar.getMinutes() > ParkingMeter.getMinPurchased()) {
    if(time <= 60) {
    ticket = 25;

    }

    else {
    ticket = 25 + (10 * (time/60));
    }
    }
    return ticket;

    }

    }

    ______________

    public class Demo

    {

    public static void main(String[] args) {

    ParkedCar car = new ParkedCar();

    ParkingMeter meter = new ParkingMeter();

    PoliceOfficer john = new PoliceOfficer();

    ParkingTicket ticket = PoliceOfficer.search(car, meter);

    if(ticket != null) {
    System.out.println(ticket);
    }
    else {
    System.out.println("Car is not doing anything wrong!");
    }
    }

    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Java Parked Simulator HELP PLEASE!

    Suggestions:
    • You will want to post the actual and complete error message.
    • You will want to indicate by a comment in your code the line(s) causing the error.
    • Please surround your posted code with [code=java] [/code] tags so that it will be readable. Note that the top tag is different from the bottom tag.

Similar Threads

  1. Developing a simulator
    By jack_nutt in forum AWT / Java Swing
    Replies: 1
    Last Post: September 5th, 2012, 07:06 AM
  2. Java TreeMap Simulator
    By giga97 in forum Collections and Generics
    Replies: 2
    Last Post: October 18th, 2011, 09:46 AM
  3. Creating a Simulator
    By william in forum Java Theory & Questions
    Replies: 4
    Last Post: June 16th, 2011, 10:11 AM
  4. [SOLVED] Java Noob: Coin Toss Simulator (no GUI)
    By bgroenks96 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 4th, 2011, 10:28 PM
  5. JAVA simulator
    By YAS218 in forum Java Theory & Questions
    Replies: 8
    Last Post: July 20th, 2009, 09:57 AM