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: trouble finding object

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default trouble finding object

    public class PoliceOfficer
    {
    String officerName;
    double badgeNumber;
    ParkedCar carInfo;
    ParkingMeter meter;
    double timeParked;
    double timePurchased;
     
     
    //constructor to get name and badge number
    PoliceOfficer(String name,double number,ParkedCar car,ParkingMeter met)
    {
    officerName=name;
    badgeNumber=number;
    carInfo=car;
    meter=met;
     
    }
     
     
    public ParkingTicket ticketTest()
    {
    if(carInfo.getMinutesParked()>meter.getMinutesPurchased())
    {
    ParkingTicket ticket=new ParkingTicket(carInfo.getMinutesParked(),meter.getMinutesPurchased(),carInfo);
    }
    return ticket;
    }
     
     
    public String toString()
         { 
             String str=" "+ticketTest()+" the officers name and badge number are "+officerName+" and "+badgeNumber;
             return str;
          }

    public class ParkingTicket
    {
    private double minutesParked;
    private double minutesPurchased;
    double fineAmount=25;
    ParkedCar carInfo;
    //constructor to get car and meter data
    ParkingTicket(double parked, double purchased,ParkedCar car)
    {
    minutesParked=parked;
    minutesPurchased=purchased;
    carInfo=car;
    }
     
    //method to return the fine amount
    public double getFineAmount()
    {
    for(double i=minutesParked;i<minutesPurchased;i++)
    {
    fineAmount=fineAmount+10;
    }
    return fineAmount;
    }
     
    public String toString()
          {
             String str=carInfo+" your fine amount is "+getFineAmount();
             return str;
          }
     
     
     
    }
    My error message tells me that in the police officer class it can not find ticket where it says "return ticket" inside the ticketTest method
    thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: trouble finding object

    Please copy the full text of the error message and paste it here.

    Where is the variable ticket defined?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Trouble with Object Collision
    By Gravity Games in forum Object Oriented Programming
    Replies: 1
    Last Post: November 29th, 2012, 11:49 AM
  2. [SOLVED] Having trouble with setting an array object
    By johnnyDidge in forum Object Oriented Programming
    Replies: 0
    Last Post: October 9th, 2012, 03:01 PM
  3. Replies: 3
    Last Post: July 12th, 2012, 07:11 AM
  4. Finding the edges of object in photo
    By Picker in forum Algorithms & Recursion
    Replies: 1
    Last Post: April 20th, 2012, 11:32 PM
  5. finding the largest object help
    By nickypass in forum Object Oriented Programming
    Replies: 4
    Last Post: October 16th, 2010, 05:48 PM