|
-
October 25th, 2010, 06:29 AM
#1
Classes implementation Problem
Hello everyone, I really hope someone can help me on this as I am trying to learn java and I know classes are really important but I am not being able to understand how it works.
Basically I made two classes,one which does the calculations,sets data and gets data and I called it carDealership,the other class is called carInterface and,as the name suggests,is the interface from where data is sent to be set by the carDealership class.
This is the carDealership class
public class carDealership {
/**
* @param args
*/
//Initializing public variables
String regNumber,make;
int year;
double value;
public carDealership(String setRegNum,String setMake,int setYear,
double setValue)
{
this.regNumber=setRegNum;
this.make=setMake;
this.year=setYear;
this.value=setValue;
}
public void printInfo()
{
System.out.println(regNumber + "-" + make + "-" +
year + "-" + value );
}
public String getRegNo()
{
return regNumber;
}
public String getMake()
{
return make;
}
public int getYear()
{
return year;
}
public double getValue()
{
return value;
}
public void setValue(double setValue)
{
this.value=setValue;
}
}
after making this class I did not have any error but now I needed something to interact with this class and I used carInterface
--------------------------------------------------
import java.io.*;
public class carInterface extends carDealership {
/**
* @param args
*/
String rNames="saghar",rNumb="08455";
int yr=2010;
double price=20000;
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public carInterface(String rName,String rNum,int year,double price)
{
super(rName,rNum,year,price);
}
}
I know this class might be a bit confusing but it's imcomplete as I don't know how to go further.
What I am trying to do,for testing the class,is set some variables to be sent to the carDealership class in order to set them and then retrive them through other methods and print them out to see if they have been stored properly.
Once i know the two classes are interacting with each other I can then use user input code to let the user set the data and decide what data he/she wants to retrive.
I hope someone can help me on how to set these classes.
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|