I need help getting started

Project for School...

Page 1 of 1

1 Replies - 501 Views - Last Post: 08 March 2010 - 02:30 PM Rate Topic: -----

#1 kweef19  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 108
  • Joined: 19-January 10

I need help getting started

Posted 08 March 2010 - 01:44 PM

okay I recently did a school project in which I made a class and defined a constructor for said class. The class I created was called EventSite. In the main project I used the constructor to call EventSite and pass an integer to it. In this project I wanna modify my original code and create another overloaded constructor for the EventSite class. The constructor will require a site number, a fee, and a manager name as arguments. I know what I want to do, but I am having trouble getting started with it. Any help or guidance would be greatly appreciated. Here is the code for my original project...
public class DemoConstructor
{
	public static void main(String[] args)
	{
		EventSite site1 = new EventSite();
		EventSite site2 = new EventSite(678);
		display(site1);
		display(site2);
	}
	public static void display(EventSite site)
	{
		System.out.println("\nEvent site #" + site.getSiteNumber() + 
			"\nFee is $" + site.getFee() +
			"\nName of site is " + site.getName());
	}
	}



And here is the coding I created for the EventSite class...

public class EventSite
{
        private int siteNumber;
        private double fee;
        private String name;
        public EventSite(){
                siteNumber = 999;
                fee = 0;
                name = "XXX";
        }
        public EventSite(int n){
                siteNumber = n;
                fee = 0;
                name = "YYY";
        }
        public int getSiteNumber()
        {
                return siteNumber;
        }
        public void setSiteNumber(int n)
        {
                siteNumber = n;
        }
        public double getFee()
        {
                return fee;
        }
        public void setFee(double n)
        {
                fee = n;
        }
        public String getName()
        {
                return name;
        }
        public void setName(String n)
        {
                name = n;
        }
}




I know I say this a lot, but you guys are amazing...I hope that one day soon I'll be able to log onto this site and help the beginners the way that all of you help me on a day-to-day basis. THANK YOU ALL SO MUCH!

Is This A Good Question/Topic? 0
  • +

Replies To: I need help getting started

#2 NoobKnight  Icon User is offline

  • D.I.C Head

Reputation: 49
  • View blog
  • Posts: 238
  • Joined: 14-July 09

Re: I need help getting started

Posted 08 March 2010 - 02:30 PM

You will want to do that same thing you did for the constructor public EventSite(int n){
except now you want to also pass a fee and name, just pass an int, a double and a string to your new constructor.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1