Click here to Skip to main content
15,895,777 members

Compiling OOP in Java

Andrew_Borg asked:

Open original thread
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
Tags: Java, Linux, OOP

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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