Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi
I would like to Ask a Question about compiling an OOP Java application.


Below is a Class Called ComputerGame.java which holds Game Details.

Java
package OOP;

public class ComputerGame
{
	private String Name;
	private String Description;
	private float Cost;
	private boolean Released;
	private final String Publisher = "TriWorld Studios";
	
	public ComputerGame(String Name)
	{
		Name = this.Name;
	}
	
	public ComputerGame(String Name, float  Cost)
	{
		Name = this.Name;
		Cost = this.Cost;
	}
	
	public static void Buy()
	{
		System.out.println(" The Buy Method ");
	}
	
	public static void Play()
	{
		
		System.out.println(" The Play Method ");
	}
	
	public static void Store()
	{	
		System.out.println(" The Store Method ");
	}
	
	public static void Sell()
	{
		System.out.println(" The Sell Method ");
	}
	
	
	
	public String GetName()
	{
		return Name;
	}
	
	public String GetDescription()
	{
		return Description;
	}
	
	public float GetCost()
	{
		return Cost;
	}
	
	public boolean GetReleased()
	{
		return Released;
	}
	
	
	public void SetName(String Name)
	{
		Name = this.Name;
	}
	
	public void SetDescription(String Description)
	{
		Description = this.Description;
	}
	
	public void SetCost(float Cost)
	{
		Cost = this.Cost;
	}
	
	public void SetReleased(boolean Released)
	{
		Released = this.Released;
	}
	
	
	
	
}


Below is the Main Class which is supposed to create an Object of type Computer Game

Java
package OOP;

public class ComputerGameMain
{
	public static void main(String[] args)
	{
		ComputerGame FierceArmour 		= 		new ComputerGame("Fierce Armour", "A Strategy Game");
		ComputerGame Tennis3D 			= 		new ComputerGame("Tennis 3D", "A Sports Game");
		ComputerGame TwoDCarton 		= 		new ComputerGame("2DCarton", "An Arcafe Game");
		
		FierceArmour.setCost(56.45);
		FierceArmour.setReleased(true);

		Tennis3D.setCost(76.34);
		Tennis3D.setReleased(false);
		
		TwoDCarton.setCost(23.99);
		TwoDCarton.setReleased(true);
	}
}


I am using a Text Editor to create this Application ( Geany ).

I Would like to know ho to link the CoumputerGame Class to the Main Class and how to compile these using javac or any other compiler.

Thank You,

Andrew Borg
Posted
Comments
Sergey Alexandrovich Kryukov 4-Nov-12 11:54am    
As there is no even a tiny bit of OOP in this code, it's not clear what you are asking about.
--SA
pasztorpisti 4-Nov-12 13:28pm    
I have a guess, but I don't like guessing... :-)
Sergey Alexandrovich Kryukov 4-Nov-12 13:48pm    
I also don't like guess, even in cases I'm pretty sure what it is. OP needs to go through exact recognition of his problem first, otherwise the answer is not really useful.
--SA
pasztorpisti 4-Nov-12 13:24pm    
You started programming before learning how to program. I recommend the reverse order, first learn how to use java and then start using it. Here is the official tutorial: http://docs.oracle.com/javase/tutorial/.
Read everything that is inside the "Trails Covering the Basics" paragraph (its quite short) and after it you won't ask questions like this. I recommend compiling the program without Eclipse or Netbeans for the first time. Don't misunderstand, those IDEs are great but you should understand whats goin on under the hood.
Sergey Alexandrovich Kryukov 4-Nov-12 13:49pm    
Good point! This the real background of it.
My 5. :-)
--SA

You should use Eclipse or Netbeans as a IDE for programming.
Both are free and will guide you through development and both can also make the build for you.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900