Problem implementing Methods in a class

Hi,
I am trying to change this code :
import java.util.Scanner;
public class Test {
public static void main(String[]args) {
Scanner stdin = new Scanner(System.in);
System.out.print("Number: ");
double n = stdin.nextDouble();
System.out.println(n + " * " + n + " = " + n*n);
So that instead of everytime that I get in I have to create an a new state,
I want to create it an object that could be access for every class
and I did this but is not running:
import java.util.Scanner;
public class Miguel {
public static void main(String[]args) {
public double calc(double n)
Scanner stdin = new Scanner(System.in);
System.out.print("Number: ");
double n = stdin.nextDouble();
System.out.println(n + " * " + n + " = " + n*n);
return n
System.out.println(calc());
}

and I did this but is not running:Not only that, it's not compiling. You can't declare methods within methods, as you have done by attempting to declare calc() inside of main().
When you post code, please post it between [code] and [/code] tags (you can just use the "code" button on the message posting screen). It makes your code much easier to read by preserving the original spacing, adding syntax highliting, and it prevents accidental markup from array indices like [i].

Similar Messages

  • CRM 7.0 implement method from MVC class

    Hello, folks.  I will prefix my question with the fact that I am a relative dinosaur in the development arena, still focused primarily procedural coding practices.  Although this still serves me well, it also means that I know little about OO development.  I have had some training and can make use of such common tools as OO ALV.  However, I know next to nothing about MVC (model view controller) programming, WEB Dynpro for ABAP, etc.  I am currently assigned to a CRM project (I am also new to CRM) and have a particular requirement that I cannot seem to address with any sort of procedural-based solution (i.e. function module).
    My requirement is to create a "URL Attachment" to a service request in CRM.  To elaborate, I have created an inbound point-to-point interface (i.e. not PI/XI) from an external system using Web Services.  The Web Service I have created ultimately invokes a call to function CRMXIF_ORDER_SAVE via a wrapper function I developed with the same interface.  This function, however, does not support the creation of "URL Attachments", only "Attachment Links".  So, my approach then is to implement additional functionality in my wrapper function to create this URL Attachment via some other means.  If you have any questions regarding URL Attachments vs. Attachment Links, please let me know.
    I have scoured the function modules to no avail.  What I have found is that via MVC, the functionality on the CRM Web UI is associated with the following class: CL_GS_CM_ADDURL_IMPL.  A search in SE24 reveals that there are actually several related? classes:
    CL_GS_CM_ADDURL
    CL_GS_CM_ADDURL_CN02
    CL_GS_CM_ADDURL_CN03
    CL_GS_CM_ADDURL_CTXT
    CL_GS_CM_ADDURL_IMPL
    My question is whether I can somehow implement one of these classes to address my requirement.  Looking at the logic within the IP_TO_ADDURL method, I cannot figure out whether I can somehow leverage this and, if so, exactly what coding would be required in my wrapper function.  I should also point that, at least from a Web UI point of view, this is a two step process whereby you must first create the attachment and the actually save it. 
    Any and all insights are much appreciated.
    Thanks.

    Hi there,
    I am not familiar with the CRM classes you mention - but what you describe is pretty much standard functionality included in Generic Object Services. May that path will lead you home.
    Cheers
    Graham Robbo

  • Implementing methods in a class

    I have a class called Employee that uses getters and seters and methods from another project. I brought the code from the methods into the Employee class to run them in my class. It is supose to calculate an employee's monthly income plus commission and a seniority bonus based on years. When I compile the class I get errors. I was wondering if you java experts can look and see what my problem is. Here is the code and errors, thanks...
    public class Employee
         private String firstName, lastName,
              address, city, state,zipCode;
         private short seniority = 0;
         private double baseSalary = 500;
         private Company company;
         //constructor
         public Employee(String fn, String ln, String a, String c, String s,
              String zc, short newSeniority, double newBs, Company newCompany){
              firstName = fn;
              lastName = ln;
              address = a;
              city = c;
              state = s;
              zipCode = zc;
              seniority = newSeniority;
              baseSalary = newBs;
              company = newCompany;
         public Employee(){
              firstName = "";
              lastName = "";
              address = "";
              city = "";
              state = "";
              zipCode = "";
         public double computeCommision(double weeklyPay) {
              double thisCommission;   
           if(weeklyPay < baseSalary)
                  thisCommission = 0.00;   
           else if(weeklyPay < 1000.00)
              thisCommission = weeklyPay * .05;   
           else if(weeklyPay < 5000.00)
              thisCommission = weeklyPay * .08;   
           else if(weeklyPay >= 5000.00)
              thisCommission = weeklyPay * .10 + 400;   
           else thisCommission = 0.00;  
           return thisCommission;
         public double bonus(double weeklyPay, int yearsWorked) {
              short seniority;
            double thisCommission = computeCommission(weeklyPay);
            if (yearsWorked >= 2) // No bonus for less than two years
                 seniority = (weeklyPay * yearsWorked)/100;
            return seniority;
         public double payroll() {
              double payroll = 0.0, pay, commission, bonus, years;
            System.out.println("\nPlease enter the years you have worked for this company:");
            int response = MyInput.readInt();
            for (int i = 0; i < 4; i++)
            System.out.println("\nPlease enter you salary for week "  + (i+1) + ": ");
            pay = MyInput.readDouble();
            commission =  computeCommission(pay);
            bonus = bonus((commission + pay), response);
            payroll = payroll + pay + commission + bonus;     
            return payroll;
         public String getFirstName() { return firstName; }
         public void setFirstName(String fn) { firstName = fn; }
         public String getLastName() { return lastName; }
         public void setLastName(String ln) { lastName = ln; }
         public String getAddress() { return address; }
         public void setAddress(String a) { address = a; }
         public String getCity() { return city; }
         public void setCity(String c) { city = c; }
         public String getState() { return state; }
         public void setState(String s)     { state = s; }
         public String getZipCode()     { return zipCode; }
         public void setZipCode(String zc) { zipCode = zc; }
         public short getSeniority() { return seniority; }
         public void setSeniority(short newSeniority) { seniority = newSeniority; }
         public double getBaseSalary() { return baseSalary; }
         public void setBaseSalary(double newBs) { baseSalary = newBs; }
         public Company getCompany() { return company; } //getter method for company in company class
         public void setBank(Company newCompany) { company = newCompany; }
    }   and the errors are :
    C:\cis163\Project5_1\src\Employee.java:59: cannot resolve symbol
    symbol : method computeCommission (double)
    location: class Employee
    double thisCommission = computeCommission(weeklyPay);
    ^
    C:\cis163\Project5_1\src\Employee.java:62: possible loss of precision
    found : double
    required: short
    seniority = (weeklyPay * yearsWorked)/100;
    ^
    C:\cis163\Project5_1\src\Employee.java:70: cannot resolve symbol
    symbol : variable MyInput
    location: class Employee
    int response = MyInput.readInt();
    ^
    C:\cis163\Project5_1\src\Employee.java:75: cannot resolve symbol
    symbol : variable MyInput
    location: class Employee
    pay = MyInput.readDouble();
    ^
    C:\cis163\Project5_1\src\Employee.java:76: cannot resolve symbol
    symbol : method computeCommission (double)
    location: class Employee
    commission = computeCommission(pay);
    ^
    5 errors

    ok, sorry. I wasnt clear on what you were saying. MyInput.java is in the same folder when I compiled it. I changed my code around a little, changed some variables so it was easier for me to understand. I am still getting several errors after I wrote code for the Project which I called project5. Not sure where I am going wrong but I will post my classes and main to see if anyone can help me out.
    //Company class
    public class Company
        private String companyName;
         private String companyAddress;
         private String companyCity;
         private String companyState;
         private String companyZip ;
         //Constructor method
         public Company(String cn, String ca, String cc, String cs, String cz) {
              companyName = cn;         
              companyAddress = ca;         
              companyCity = cc;         
              companyState = cs;         
              companyZip = cz;
        public Company(){
             companyName = "";
             companyAddress = "";
             companyCity = "";
             companyState = "";
             companyZip = "";
         public String getName() { return companyName; }
        public void setName(String cn) { companyName = cn; }
         public String getAddress() { return companyAddress; }
        public void setAddress(String ca){ companyAddress = ca; }
        public String getCity() { return companyCity; }
        public void setCity(String cc) { companyCity = cc; }     
        public String getState() { return companyState; }     
        public void setState(String cs) { companyState = cs; }
        public String getZip()     { return companyZip; }     
        public void setZip(String cz) { companyZip = cz; }
    //Employee class
    public class Employee
         private String employeeFName, employeeLName,employeeAddress,
              employeeCity, employeeState, employeeZip;
         private short seniority = 0;
         private double baseSalary = 500;
         private Company company;
         //constructor
         public Employee(String efn, String eln, String ea, String ec, String es,
              String ez, short newSeniority, double newBs, Company newCompany){
              employeeFName = efn;
              employeeLName = eln;
              employeeAddress = ea;
              employeeCity = ec;
              employeeState = es;
              employeeZip = ez;
              seniority = newSeniority;
              baseSalary = newBs;
              company = newCompany;
         public Employee(){
              employeeFName = "";
              employeeLName = "";
              employeeAddress = "";
              employeeCity = "";
              employeeState = "";
              employeeZip = "";
         public double computeCommission(double weeklyPay) {
              double thisCommission;   
           if(weeklyPay < baseSalary)
                  thisCommission = 0.00;   
           else if(weeklyPay < 1000.00)
              thisCommission = weeklyPay * .05;   
           else if(weeklyPay < 5000.00)
              thisCommission = weeklyPay * .08;   
           else if(weeklyPay >= 5000.00)
              thisCommission = weeklyPay * .10 + 400;   
           else thisCommission = 0.00;  
           return thisCommission;
         public double bonus(double weeklyPay, int yearsWorked) {
              short seniority;
            double thisCommission = computeCommission(weeklyPay);
            if (yearsWorked >= 2) // No bonus for less than two years
                 seniority = (short) ((weeklyPay * yearsWorked)/100);
            return seniority;
         public double payroll() {
              double payroll = 0.0, pay, commission, bonus, years;
            System.out.println("\nPlease enter the years you have worked for this company:");
            int response = MyInput.readInt();
            for (int i = 0; i < 4; i++)
            System.out.println("\nPlease enter you salary for week "  + (i+1) + ": ");
            pay = MyInput.readDouble();
            commission =  computeCommission(pay);
            bonus = bonus((commission + pay), response);
            payroll = payroll + pay + commission + bonus;     
            return payroll;
         public String getFirstName() { return employeeFName; }
         public void setFirstName(String efn) { employeeFName = efn; }
         public String getLastName() { return employeeLName; }
         public void setLastName(String eln) { employeeLName = eln; }
         public String getAddress() { return employeeAddress; }
         public void setAddress(String ea) { employeeAddress = ea; }
         public String getCity() { return employeeCity; }
         public void setCity(String ec) { employeeCity = ec; }
         public String getState() { return employeeState; }
         public void setState(String es)     { employeeState = es; }
         public String getZipCode()     { return employeeZip; }
         public void setZipCode(String ez) { employeeZip = ez; }
         public short getSeniority() { return seniority; }
         public void setSeniority(short newSeniority) { seniority = newSeniority; }
         public double getBaseSalary() { return baseSalary; }
         public void setBaseSalary(double newBs) { baseSalary = newBs; }
         public Company getCompany() { return company; } //getter method for company in company class
         public void setBank(Company newCompany) { company = newCompany; }
    public class Project5 { //Beginning of class Project5
    public static void main (String args[]) { //Beginning of main
            //Company
            String companyName = "";
            String companyAddress = "";
            String companyCity = "";
            String companyState = "";
            String companyZip = "";
            // Creates a new Company object called aCompany
            Company aCompany = new Company( companyName, companyAddress,
                 companyCity, companyState, companyZip );
            // Prompts user about information about company
            // and sets fields for the Company object.
            System.out.println( "***Company Information***" );
            System.out.println( "Please enter information about company:");
            System.out.println();
            System.out.print( "Company name: " );
            companyName = MyInput.readString();
            aCompany.setName( companyName );
            System.out.print( "Company address: " );
            companyAddress = MyInput.readString();
            aCompany.setAddress( companyAddress );
            System.out.print( "Company city: " );
            companyCity = MyInput.readString();
            aCompany.setCity( companyCity );
            System.out.print( "Company state: " );
            companyState = MyInput.readString();
            aCompany.setState( companyState );
            System.out.print( "Company zip: " );
            companyZip = MyInput.readString();
            aCompany.setZip( companyZip );
            System.out.println();
            // Employee
            String employeeFName = "";
            String employeeLName = "";
            short seniority = 0;
            String employeeAddress = "";
            String employeeCity = "";
            String employeeState = "";
            String employeeZip = "";
            // Creates a new Employee object called anEmployee who works for the above company.
            Employee anEmployee = new Employee( employeeFName,employeeLName, seniority,
                 employeeAddress, employeeCity, employeeState, employeeZip, aCompany );
            // Prompts user about information about employee
            // and sets fields for the Employee object.
            System.out.println( "***Employee Information***" );
            System.out.println( "Please enter information about an employee:");
            System.out.println();
            System.out.print( "Employee first name: " );
            employeeFName = MyInput.readString();
            anEmployee.setFirstName( employeeFName );
            System.out.print( "Employee last name: " );
            employeeLName = MyInput.readString();
            anEmployee.setLastName( employeeLName );
            System.out.print( "Employee address: " );
            employeeAddress = MyInput.readString();
            anEmployee.setAddress( employeeAddress );
            System.out.print( "Employee city: " );
            employeeCity = MyInput.readString();
            anEmployee.setCity( employeeCity );
            System.out.print( "Employee state: " );
            employeeState = MyInput.readString();
            anEmployee.setState( employeeState );
            System.out.print( "Employee zip: " );
            employeeZip = MyInput.readString();
            anEmployee.setZip( employeeZip );
            System.out.print( "How many years the employee has been with the company? : " );
            seniority = (short)MyInput.readInt();
            anEmployee.setSeniority( seniority );
            System.out.println();
            // Displays company information
            System.out.println( "*** Company Information Summary ***" );
            System.out.println( "Company name:    " + aCompany.getName());
            System.out.println( "Company address: " + aCompany.getAddress() );
            System.out.println( "Company city:    " + aCompany.getCity() );
            System.out.println( "Company state:   " + aCompany.getState() );
            System.out.println( "Company zip:     " + aCompany.getZip() );
            System.out.println();
            // Displays employee information
            System.out.println( "*** Employee Information Summary ***");
            System.out.println( "Employee firstName:  " + anEmployee.getFirstName() );
            System.out.println( "Employee lastName:   " + anEmployee.getLastName() );
            System.out.println( "Employee seniority:  " + anEmployee.getSeniority() );
            System.out.println( "Employee baseSalary: $" + anEmployee.getBaseSalary() );
            System.out.println( "Employee address:    " + anEmployee.getAddress() );
            System.out.println( "Employee city:       " + anEmployee.getCity() );
            System.out.println( "Employee state:      " + anEmployee.getState() );
            System.out.println( "Employee zip:        " + anEmployee.getZip() );
            // We retrieve the company name from anEmployee object.
            System.out.println( "Company name the employee works for: "
                 + anEmployee.getCompany().getName() );
            // Calls payroll() to calculate one month salary
            System.out.println();
            System.out.println( "*** Calculate monthly pay *** " );
            double oneMonthSalary = anEmployee.payroll(); // Calls payroll()
            DecimalFormat myDecimalFormat = new DecimalFormat( "0.00" );
    // Instantiate DecimalFormat object
            // Format one month salary and display to console
            System.out.println();
            System.out.println( "One month salary is: $" + myDecimalFormat.format(oneMonthSalary) );
            System.out.println();
    }sorry, its alot. I'm getting 18 errors, which are:
    C:\cis163\Project5_1\src\Project5.java:24: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyName = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:28: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyAddress = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:32: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyCity = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:36: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyState = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:40: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyZip = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:56: cannot resolve symbol
    symbol : constructor Employee (java.lang.String,java.lang.String,short,java.lang.String,java.lang.String,java.lang.String,java.lang.String,Company)
    location: class Employee
    Employee anEmployee = new Employee( employeeFName,employeeLName, seniority,
    ^
    C:\cis163\Project5_1\src\Project5.java:66: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeFName = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:70: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeLName = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:74: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeAddress = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:78: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeCity = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:82: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeState = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:86: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeZip = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:87: cannot resolve symbol
    symbol : method setZip (java.lang.String)
    location: class Employee
    anEmployee.setZip( employeeZip );
    ^
    C:\cis163\Project5_1\src\Project5.java:90: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    seniority = (short)MyInput.readInt();
    ^
    C:\cis163\Project5_1\src\Project5.java:114: cannot resolve symbol
    symbol : method getZip ()
    location: class Employee
    System.out.println( "Employee zip: " + anEmployee.getZip() );
    ^
    C:\cis163\Project5_1\src\Project5.java:127: cannot resolve symbol
    symbol : method payroll ()
    location: class Employee
    double oneMonthSalary = anEmployee.payroll(); // Calls payroll()
    ^
    C:\cis163\Project5_1\src\Project5.java:129: cannot resolve symbol
    symbol : class DecimalFormat
    location: class Project5
    DecimalFormat myDecimalFormat = new DecimalFormat( "0.00" );
    ^
    C:\cis163\Project5_1\src\Project5.java:129: cannot resolve symbol
    symbol : class DecimalFormat
    location: class Project5
    DecimalFormat myDecimalFormat = new DecimalFormat( "0.00" );
    ^
    18 errors

  • Implement method inside abstract class?

    hello everyone:
    I have a question regarding implementation of method inside a abstract class. The abstract class has a static method to swamp two numbers.
    The problem ask if there is any output from the program; if no output explain why?
    This is a quiz question I took from a java class. I tried the best to recollect the code sample from my memory.
    if the code segment doesn't make sense, could you list several cases that meet the purpose of the question. I appreciate your help!
    code sample
    public abstract class SwampNumber
       int a = 4;
       int b = 2;
       System.out.println(a);
       System.out.println(b);
       swamp(a, b);
       public static void swamp(int a, int b)
         int temp = a;
             a = b;
             b = a;
         System.out.println(a);
         System.out.println(b);

    It won't compile.
    You can't instantiate an abstract class before you know anything.
    //somewhere in main
    SwampNumber myNum = new SwampNumber();
    //Syntax ErrorQuote DrClap
    This error commonly occurs when you have code that >>is not inside a method.
    The only statements that can appear outside methods >>in a Java class are >>declarations.Message was edited by:
    lethalwire

  • Implementation method SEARCH_FOR_NEXT_PROCESSOR of Class PT_GEN_REQ

    Hi All,
    we are trying to implement BADI u201CFind next processoru201D  of the implementation PT_GEN_REQ and we would like to filter the next processor according to the absence/attendance type which is not one of parameters of the method SEARCH_FOR_NEXT_PROCESSOR.
    Is there a way to do so?
    Thanks in advace for your help,
    Amedeo

    Hi Harald,
    to check the user defined entries, I suggest you implement it in the START_WF method. There's a method call:
        CALL METHOD lc_step->agent_append
          EXPORTING
            agent          = l_agent
          EXCEPTIONS
            already_exists = 1
            locked         = 2
            OTHERS         = 3.
    which adds the agents to the recipient list. The validation could be put before this I think.
    Hope this helps,
    Mikko

  • Problem using repaint() method from another class

    I am trying to make tower of hanoi...but unable to transfer rings from a tower to another...i had made three classes....layout21 where all componentents of frame assembled and provided suitable actionlistener.....second is mainPanel which is used to draw the rods n rings in paintComponent.....and third is tower in which code for hanoi is available...i had made an object of mainPanel at layoout21 n tower but i m not able to call repaint from tower..gives an error : cannot find the symbol....method repaint in tower.
    code fragments od three classes are:
    LAYOUT21
    class layout21 extends JFrame implements ActionListener
    { private Vector rod1 = new Vector();
    private Vector rod2 = new Vector();
    private Vector rod3 = new Vector();
    private String elem; //comment
    public String r22;
    public boolean in=false;
    public int count=0; //no of times the transfer to other rods performed
    private int r3,rings; // current no of rings
    private JComboBox nor,col;
    private JLabel no;
    private JLabel moved;
    private JLabel no1;
    private JButton start;
    private JButton ref;
    private AboutDialog dialog;
    private JMenuItem aboutItem;
    private JMenuItem exitItem;
    private tower t;
    final mainPanel2 p =new mainPanel2();
    public layout21()
    { t = new tower();
         Toolkit kit =Toolkit.getDefaultToolkit();
    Image img = kit.getImage("java.gif");
    setIconImage(img);
    setTitle("Tower Of Hanoi");
    setSize(615,615);
    setResizable(false);
    setBackground(Color.CYAN);
         JMenuBar mbar = new JMenuBar();
    setJMenuBar(mbar);
    JMenu fileMenu = new JMenu("File");
    mbar.add(fileMenu);
    aboutItem = new JMenuItem("About");
    aboutItem.addActionListener(this);
    fileMenu.add(aboutItem);
    exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(this);
    fileMenu.add(exitItem);
    Container contentPane =getContentPane();
    JPanel bspanel = new JPanel();
    JPanel bnpanel = new JPanel();
    setBackground(Color.CYAN);
         //JComboBox
    nor = new JComboBox();
    nor.setEditable(false);
    nor.addItem("3");
    nor.addItem("4");
    nor.addItem("5");
    nor.addItem("6");
    nor.addItem("7");
    nor.addItem("8");
    nor.addItem("9");
    bspanel.add(nor);
    col = new JComboBox();
    col.setEditable(false);
    col.addItem("BLACK");
    col.addItem("GREEN");
    col.addItem("CYAN");
    bspanel.add(col);
    JLabel tl = new JLabel("Time");
    tl.setFont(new Font("Serif",Font.BOLD,12));
    bspanel.add(tl);
    JTextField tlag = new JTextField("0",4);
    bspanel.add(tlag);
    start =new JButton("Start");
    bspanel.add(start);
    ref =new JButton("Refresh");
    bspanel.add(ref);
    JButton end =new JButton("End");
    bspanel.add(end);
    start.addActionListener(this);
    nor.addActionListener(this);
    col.addActionListener(this);
    ref.addActionListener(this);
    end.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    dispose(); // Closes the dialog
    contentPane.add(bspanel,BorderLayout.SOUTH);
    JLabel count = new JLabel("No of Transfer reguired:");
    count.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(count);
    no = new JLabel("7");
    no.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(no);
    JLabel moved = new JLabel("Moved:");
    moved.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(moved);
    no1 = new JLabel("0");
    no1.setFont(new Font("Serif",Font.BOLD,16));
    bnpanel.add(no1);
    contentPane.add(bnpanel,BorderLayout.NORTH);
    contentPane.add(p,BorderLayout.CENTER);
         String r = (String)nor.getSelectedItem();
    rings = Integer.valueOf(r).intValue();
    p.draw(rings,1) ;
    public void actionPerformed(ActionEvent evt)
    {  Object source = evt.getSource();
    if(source == start)
    r3 = Integer.valueOf((String)nor.getSelectedItem()).intValue();
    p.transfer(false);
    t.initialise(rod1,rod2,rod3,0);
    t.towerOfHanoi(r3);
         //repaint();
         if(source == ref)
    { rod1.removeAllElements() ;
    rod2.removeAllElements() ;
    rod3.removeAllElements() ;
    count=0;
              r3 = Integer.valueOf((String)nor.getSelectedItem()).intValue();
              p.draw(r3,1);
    p.transfer(true);
    no1.setText(""+0);
    p.trans_vec(rod1,rod2,rod3);
    t.initialise(rod1,rod2,rod3,0);
              System.out.println("");
              repaint();
    if(source == nor)
    { JComboBox j = (JComboBox)source;
    String item = (String)j.getSelectedItem();
    int ring1 = Integer.valueOf(item).intValue();
    int a=1;
    for(int i=1;i<=ring1;i++)
    { a = a*2;
    a=a-1;
    no.setText(""+a);
    p.draw(ring1,1);
    repaint();
    if(source == aboutItem)
    {  if (dialog == null) // first time
    dialog = new AboutDialog(this);
    dialog.setVisible(true);
    if(source == exitItem)
    {  System.exit(0);
         if (source==col)
         { JComboBox j = (JComboBox)source;
    String item = (String)j.getSelectedItem();
              repaint();
    TOWER
    class tower extends Thread
    { private Vector rod1 = new Vector();
    private Vector rod2 = new Vector();
    private Vector rod3 = new Vector();
    private int count ;
    private String elem;
    final mainPanel2 z =new mainPanel2();
    public void initialise(Vector r1,Vector r2,Vector r3,int c)
    { rod1 = r1;
    rod2 = r2;
         rod3 = r3;
         count =c;
    public void towerOfHanoi(int rings)
    for(int i=0;i<rings;i++)
    rod1.add(" "+(i+1));
    System.out.println("rod1:"+rod1.toString());
    hanoi(rings,1,2);
    public void hanoi(int m,int i, int j)
    if(m>0)
    { hanoi(m-1,i,6-i-j);
    if(i==1 && j==2 && rod1.isEmpty()==false)
    { count++;
    //no1.setText(""+count);
    elem = (String)rod1.remove(0);
    rod2.add(0,elem);
         //z.trans_vec(rod1,rod2,rod3);
    repaint(); //NOT ABLE TO USE METHOD HERE...WHY??
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 2:"+rod2.toString());
    if(i==1 && j==3 && rod1.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
         elem = (String)rod1.remove(0);
    rod3.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();//
    // z.hanoi_paint();
                   try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 3:"+rod3.toString());
    if(i==2 && j==1 && rod2.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
         elem = (String)rod2.remove(0);
    rod1.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 1:"+rod1.toString());
    if(i==2 && j==3 && rod2.isEmpty()==false)
    { count++;     
         //no1.setText(""+count);
         elem = (String)rod2.remove(0);
    rod3.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 3:"+rod3.toString());
    if(i==3 && j==1 && rod3.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
    elem = (String)rod3.remove(0);
    rod1.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
         try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 1:"+rod1.toString());
    if(i==3 && j==2 && rod3.isEmpty()==false)
    { count++;
         //no1.setText(""+count);
    elem = (String)rod3.remove(0);
    rod2.add(0,elem);
    //z.trans_vec(rod1,rod2,rod3);
    repaint();
    //z.hanoi_paint();
    try
              this.sleep(2000);      
              catch (Exception e) { e.printStackTrace() ;  }
    System.out.println(count+". ROD 2:"+rod2.toString());
    hanoi(m-1,6-i-j,j);
    MAINPANEL
    class mainPanel2 extends JPanel //throws IOException
    public Vector line = new Vector();
    public Vector rod11= new Vector();
    public Vector rod22= new Vector();
    public Vector rod33= new Vector();
    public int no_ring;
    public int rod_no;
    String pixel;
    StringTokenizer st,st1;
    int x,y;
    public boolean initial =true;
    public void paintComponent(Graphics g)
    { System.out.println("repaint test");
    bresenham(100,60,100,360);
         bresenham(101,60,101,360);
    bresenham(102,60,102,360);
    bresenham(103,60,103,360);
    bresenham(104,60,104,360);     
    g.setColor(Color.BLUE);
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    bresenham(300,60,300,360);
    bresenham(301,60,301,360);
    bresenham(302,60,302,360);
    bresenham(303,60,303,360);
    bresenham(304,60,304,360);     
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    bresenham(500,60,500,360);
    bresenham(501,60,501,360);
    bresenham(502,60,502,360);
    bresenham(503,60,503,360);
    bresenham(504,60,504,360);     
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    bresenham(0,361,615,361);//used to get a pixel according to algo.. . func not provided
    bresenham(0,362,615,362);
    bresenham(0,363,615,363);
    bresenham(0,364,615,364);
    bresenham(0,365,615,365);     
    while(line.size()>0)
    { pixel = (String)line.remove(0);
    st = new StringTokenizer(pixel);
    x = Integer.valueOf(st.nextToken()).intValue();
    y = Integer.valueOf(st.nextToken()).intValue();
    g.drawLine(x,y,x,y);
    if(initial==true)
    g.setColor(Color.RED);
    for(int i = no_ring;i>0;i--)
    { g.drawLine(100-(i*8),360-(no_ring - i)*10,100+(i*8)+5,360-(no_ring - i)*10);
    g.drawLine(100-(i*8),359-(no_ring - i)*10,100+(i*8)+5,359-(no_ring - i)*10);
    g.drawLine(100-(i*8),358-(no_ring - i)*10,100+(i*8)+5,358-(no_ring - i)*10);
    g.drawLine(100-(i*8),357-(no_ring - i)*10,100+(i*8)+5,357-(no_ring - i)*10);
    g.drawLine(100-(i*8),356-(no_ring - i)*10,100+(i*8)+5,356-(no_ring - i)*10);
    // draw for each rod
    //System.out.println("rod11:"+rod11);
    //System.out.println("rod22:"+rod22);
    //System.out.println("rod33:"+rod33);
         int r1 = rod11.size();
         int r2 = rod22.size();
         int r3 = rod33.size();
    String rd1,rd2,rd3;
    int r11,r12,r21,r22,r31,r32;
    if(initial == false)
         { g.setColor(Color.RED);
         while(rod11.size()>0)
    { r12 = rod11.size()-1;
              rd1 = (String)rod11.remove(r12);
    r11 = Integer.valueOf(rd1).intValue();
    g.drawLine(100-((r11+1)*8),360-(r1 - (r11+1))*10,100+((r11+1)*8)+5,360-(r1 - (r11+1))*10);
    g.drawLine(100-((r11+1)*8),359-(r1 - (r11+1))*10,100+((r11+1)*8)+5,359-(r1 - (r11+1))*10);
              g.drawLine(100-((r11+1)*8),358-(r1 - (r11+1))*10,100+((r11+1)*8)+5,358-(r1 - (r11+1))*10);
              g.drawLine(100-((r11+1)*8),357-(r1 - (r11+1))*10,100+((r11+1)*8)+5,357-(r1 - (r11+1))*10);
              g.drawLine(100-((r11+1)*8),356-(r1 - (r11+1))*10,100+((r11+1)*8)+5,356-(r1 - (r11+1))*10);
         while(rod22.size()>0)
    { g.setColor(Color.RED);
              r22 = rod22.size()-1;
         System.out.println("TEST *************************:"+r22);
              try
         // e.printStackTrace();      
              InputStreamReader isr = new InputStreamReader(System.in);
         BufferedReader br = new BufferedReader(isr)      ;
         br.readLine() ;
         }catch(Exception f) {}
              rd2 = ((String)rod22.remove(r22)).trim();
    r21 = Integer.valueOf(rd2).intValue();
    g.drawLine(300-((r22+1)*8),360-(r2 - (r22+1))*10,300+((r22+1)*8)+5,360-(r2 - (r22+1))*10);
    g.drawLine(300-((r22+1)*8),359-(r2 - (r22+1))*10,300+((r22+1)*8)+5,359-(r2 - (r22+1))*10);
              g.drawLine(300-((r22+1)*8),358-(r2 - (r22+1))*10,300+((r22+1)*8)+5,358-(r2 - (r22+1))*10);
              g.drawLine(300-((r22+1)*8),357-(r2 - (r22+1))*10,300+((r22+1)*8)+5,357-(r2 - (r22+1))*10);
              g.drawLine(300-((r22+1)*8),356-(r2 - (r22+1))*10,300+((r22+1)*8)+5,356-(r2 - (r22+1))*10);
         while(rod33.size()>0)
    { g.setColor(Color.RED);
              r32 = rod33.size()-1;
              rd3 = (String)rod33.remove(r32);
    r31 = Integer.valueOf(rd3).intValue();
    g.drawLine(500-((r32+1)*8),360-(r3 - (r32+1))*10,500+((r32+1)*8)+5,360-(r3 - (r32+1))*10);
    g.drawLine(500-((r32+1)*8),359-(r3 - (r32+1))*10,500+((r32+1)*8)+5,359-(r3 - (r32+1))*10);
              g.drawLine(500-((r32+1)*8),358-(r3 - (r32+1))*10,500+((r32+1)*8)+5,358-(r3 - (r32+1))*10);
              g.drawLine(500-((r32+1)*8),357-(r3 - (r32+1))*10,500+((r32+1)*8)+5,357-(r3 - (r32+1))*10);
              g.drawLine(500-((r32+1)*8),356-(r3 - (r32+1))*10,500+((r32+1)*8)+5,356-(r3 - (r32+1))*10);
    why i m not able to use repaint() method in tower class? from where i can use repaint() method

    i can't read your code - not formatted with code tags
    I have no chance of getting it to compile (AboutDialog class?? p.draw() ??)
    here's a basic routine - add a couple of things to this to demonstrate what is not
    being redrawn
    (compare the readability of below code (using tags) to yours)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Testing extends JFrame
      public Testing()
        setSize(400,300);
        setLocation(400,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        final DrawPanel dp = new DrawPanel();
        JButton btn = new JButton("Change Text Location/Repaint");
        getContentPane().add(dp,BorderLayout.CENTER);
        getContentPane().add(btn,BorderLayout.SOUTH);
        btn.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            dp.x = (int)(Math.random()*300);
            dp.y = (int)(Math.random()*150)+50;
            repaint();}});
      public static void main(String[] args){new Testing().setVisible(true);}
    class DrawPanel extends JPanel
      int x = 50, y = 50;
      public void paintComponent(Graphics g)
        super.paintComponent(g);
        g.drawString("Hello World",x,y);
    }

  • Problems calling a method in another class

    I have the following method in a class called recordCalls -
    public static void objectCreated(String type, String name)
            System.out.println("An object of type " + type + " called " + name + " has been created.");
    //       addObjectToPanel(type, name);  
        }I am attempting to call addObjectToPanel(type, name) which is a method inside a class called test.
    I do not want to create an instance of test an call it like test.addObjectToPanel(type, name)
    Is there any other way of doing this.
    Thanks.

    You either have to make the method static, and call
    test.addObjectToPanel or you have to create an
    instance of test and invoke the method on that
    instance.
    I don't know what that class is supposed to do, so I
    don't know which is more appropriate.
    You should name your classes starting with capital
    letters, and Test is a very undescriptive (and hence
    bad) name for that class.I will be chaning the names of everything when the class works.
    Test contains the UI for my program.
    When I run test then my UI is runing, once I run addObjectToPanel from the record calls class it should put images into my UI,
    the problem is that each time the method is run it open up a different UI and adds an image to it instead of just adding the images to the window which is already open.

  • Problem with getState() method in Thread class

    Can anyone find out the problem with the given getState() method:
    System.out.println("The state of Thread 1: "+aThread.getState());
    The Error message is as follows:
    threadDemo.java:42: cannot resolve symbol
    symbol : method getState ()
    location: class incrementThread
    System.out.println("The state of Thread 1: "+aThread.getState())
    ^
    1 error

    the api doc shows Since: 1.5
    You do use Java 5...if not... it's not available.

  • Calling an implemented method from an external class.

    Hey guys...
    I'm writing a package to be put into a program I'm writing for a project (for Uni), but I also want to use the package in other programs.
    Basically, the package will return a JScrollPane that can be put into any JFrame or JPanel or whatever.
    It draws boxes on the JScrollPane in different colours and locations depending on what information is passed to it (kind of like iCal or Microsoft Outlook Calendar), and is to be used for a Resource Allocation Program that requires drag and drop of boxes for moving bookings around etc.
    http://www.pixel2.com.au/ethos/class_diagram.png
    This is a copy of the class diagram for the relevant classes. ViewFrame is the class that instantiates the JScrollPane (AllocationTable). It implements the AllocationInterface to implement methods such as moveAllocation() newAllocation() etc.
    BookingPanel is the content pane for the JScrollPane. AllocatedBox is the individual bookings, or boxes that are painted onto the BookingPanel.
    BookingPanel implements ActionListener, MouseListener and MouseMotionListener, which enables drag and drop functionality.
    What I want to do, is when mouseReleased() is called by dropping a box, call the method moveAllocation() in ViewFrame to make the changes to the database to move the booking around.
    I don't know how to access that from BookingPanel as the name of ViewFrame will change obviously for different programs.
    If you could help me out, that would be great!
    If you need anything else explained, please let me know.
    Thanks,
    Ryan.

    LeRyan wrote:
    Hey guys...
    I'm writing a package to be put into a program I'm writing for a project (for Uni), but I also want to use the package in other programs.
    Basically, the package will return a JScrollPane that can be put into any JFrame or JPanel or whatever.I think you have some terminology issues that might stand in your way of getting help or understanding the issues. A Package is a grouping of classes, so a package doesn't return anything...
    It draws boxes on the JScrollPane in different colours and locations depending on what information is passed to it (kind of like iCal or Microsoft Outlook Calendar), and is to be used for a Resource Allocation Program that requires drag and drop of boxes for moving bookings around etc.So from your description of the function of this thing, I think you mean a class - some sort of JComponent?
    >
    http://www.pixel2.com.au/ethos/class_diagram.png
    This is a copy of the class diagram for the relevant classes. ViewFrame is the class that instantiates the JScrollPane (AllocationTable). It implements the AllocationInterface to implement methods such as moveAllocation() newAllocation() etc.
    BookingPanel is the content pane for the JScrollPane. AllocatedBox is the individual bookings, or boxes that are painted onto the BookingPanel.
    BookingPanel implements ActionListener, MouseListener and MouseMotionListener, which enables drag and drop functionality.
    What I want to do, is when mouseReleased() is called by dropping a box, call the method moveAllocation() in ViewFrame to make the changes to the database to move the booking around.
    I don't know how to access that from BookingPanel as the name of ViewFrame will change obviously for different programs.
    If I follow, and I am not sure that I do - you want a reference to the ViewFrame in the BookingPanel. So either on construction of the BookingPanel via a parameter in the constructor, or as a separate step via a setter, place a reference to the ViewFrame in BookingPanel. Then when you call mouseReleased you can call moveAllocation through that reference.
    If you could help me out, that would be great!
    If you need anything else explained, please let me know.
    Thanks,
    Ryan.

  • Question about methods in a class that implements Runnable

    I have a class that contains methods that are called by other classes. I wanted it to run in its own thread (to free up the SWT GUI thread because it appeared to be blocking the GUI thread). So, I had it implement Runnable, made a run method that just waits for the thread to be stopped:
    while (StopTheThread == false)
    try
    Thread.sleep(10);
    catch (InterruptedException e)
    //System.out.println("here");
    (the thread is started in the class constructor)
    I assumed that the other methods in this class would be running in the thread and would thus not block when called, but it appears the SWT GUI thread is still blocked. Is my assumption wrong?

    powerdroid wrote:
    Oh, excellent. Thank you for this explanation. So, if the run method calls any other method in the class, those are run in the new thread, but any time a method is called from another class, it runs on the calling class' thread. Correct?Yes.
    This will work fine, in that I can have the run method do all the necessary calling of the other methods, but how can I get return values back to the original (to know the results of the process run in the new thread)?Easy: use higher-level classes than thread. Specifically those found in java.util.concurrent:
    public class MyCallable implements Callable<Foo> {
      public Foo call() {
        return SomeClass.doExpensiveCalculation();
    ExecutorService executor = Executors.newFixedThreadPool();
    Future<Foo> future = executor.submit(new MyCallable());
    // do some other stuff
    Foo result = future.get(); // get will wait until MyCallable is finished or return the value immediately when it is already done.

  • Implementing UIApplicationDelegate protocol methods in NSObject class not working.

    Hi Everyone,
    I am new bee in iphone developement. I want to implement UIApplicationDelegate protocol methods in one of my NSObject class, how can i implement that help me please.
    I have mentioned the sample code what acutal i want to impelment.
    .h file
    @interface SmaplClass : NSObject <UIApplicationDelegate>
    .m file
    - (void)applicationWillResignActive:(UIApplication *)application
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
    Want to implement the above methods is NSObject class to be implemented or used, its not working. Help me can do it.
    Please help me
    Thanks,

    I complete the above discussion with saying that it is better to implement the notification handling methods in your app delegate. If there are good reasons to not to do so, you have to implement the methods in another class, instantiate the class, and call the methods from the actual UIApplicationDelegate protocol methods in the AppDelegate object. This way you can remove the actual notification handling code from AppDelegate class.
    For example, suppose you implemented the methods in the class called Test. This is a sample code in the AppDelegate class:
    @implementation AppDelegate
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
          Test *t = [[Test alloc] init];
         [t application: application didReceiveRemoteNotification: userInfo];
    @end
    Or you can create an association relationship between the AppDelegate and Test, so you do not have to create a new Test instance in each of the remote notification handling methods:
    @interface AppDelegate {
         Test *test;
    @end
    @implementation AppDelegate
    + (id)init {
         if (self = [super init]) {
              test = [[Test alloc] init];
         return self;
    - (void)dealloc {
         [test release];
         [super dealloc];
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
         // No need to create a Test instance. You just forward the call from AppDelegate instance to test      // instance
         [test application: application didReceiveRemoteNotification: userInfo];
    @end

  • Error When Trying to POST: Method not implemented in data provider class

    Hi Experts,
    I have created an Odata Service using Netweaver Gateway Service builder. I am using Advanced Rest Client to test the service. I can successfully GET my data, but I run into issues when I try and POST new data.
    When trying to POST, I used the GET method to get the x-csrf-token, and added it to my header. I also updated the body XML with the data that I would like to POST. However, after sending the POST request, I am getting a "500 Internal Service Error" with the xml message "Method '<OdataServiceName>'_CREATE_ENTITY" not implemented in data provider class".
    Any help on this would be greatly appreciated. Thanks!

    Hi Kelly,
    Can you share screenshots of the error? Maybe something wrong with payload :can you share the same also? Did you try to debug it by putting a breakpoint in the CREATE_ENTITY method in the backend? Any luck?
    Regards,
    JK

  • How to check (programmatic) existence of a method in a class implementation

    Hi
    I need to check the existence of method in a class in a programmatic way and call it only when it is available otherwise proceed with subsequent steps in my ABAP OO Program. Is there way to do it? This is needed in a customer exit situation and each task is implemented with method and not all tasks would have methods implemented.
    Any feedback is greatly appreciated.
    Thanks

    When you try to call the method dynamically and ifthe method doesn't exist, system would complain by raising the exception cx_sy_dyn_call_illegal_method. You can Catch this exception when you call the method.
    CLASS lcl_test DEFINITION.
      PUBLIC SECTION.
        METHODS:
          check_exist.
    ENDCLASS.                    "lcl_test DEFINITION
    DATA: lo_test TYPE REF TO lcl_test.
    DATA: lv_method TYPE char30.
    lv_method = 'GET_DATA'.
    CREATE OBJECT lo_test.
    TRY.
        CALL METHOD lo_test->(lv_method).
      CATCH cx_sy_dyn_call_illegal_method.
    ENDTRY.
    CLASS lcl_test IMPLEMENTATION.
      METHOD check_exist.
      ENDMETHOD.                    "check_exist
    ENDCLASS.
    Regards,
    Naimesh Patel

  • I need  to implement clone method  in theAdvancedDataGrid class

    I need  to implement clone method  in theAdvancedDataGrid class, to copy the object in its completeness   Could anyone give me a helping hand.

    Hi Nikos,
    from youe question it's not clear what do you need to copy: data, parts of ADG (GUI) or something else?
    If it's not a GUI - only data - you can use mx.utils.ObjectUtil.copy(value:Object):Object

  • Calling a method from abstarct class

    Hi Experts,
    Am working on ABAP Objects.
    I have created an Abstract class - with method m1.
    I have implemented m1.
    As we can not instantiate an abstract class, i tried to call the method m1 directly with class name.
    But it it giving error.
    Please find the code below.
    CLASS c1 DEFINITION ABSTRACT.
      PUBLIC SECTION.
        DATA: v1 TYPE i.
        METHODS: m1.
    ENDCLASS.                    "c1 DEFINITION
    CLASS c1 IMPLEMENTATION.
      METHOD m1.
        WRITE: 'You called method m1 in class c1'.
      ENDMETHOD. "m1
    ENDCLASS.                    "c1 IMPLEMENTATION
    CALL METHOD c1=>m1.
    Please tell me what is wrong and how to solve this problem.
    Thanks in Advance.

    Micky is right, abstract means not to be instantiated. It is just a "template" which you can use for all subsequent classes. I.e you have general abstract class vehicle . For all vehicles you will have the same attributes like speed , engine type ,  strearing , gears etc and methods like start , move etc.
    In all subsequent classes (which inherit from vehicle) you will have more specific attributes for each. But all of these classes have some common things (like the ones mentioned above), so they use abstract class to define these things for all of them.
    Moreover there is no sense in creating instance (real object) of class vehicle . What kind of physical object would vehicle be? there is no such object in real world, right? For this we need to be more precise, so we create classes which use this "plan" for real vehicles. So the abstract class here is only to have this common properties and behaviour defined in one place for all objects which will have these. Abstract object however cannot be created per se. You can only create objects which are lower in hierarchy (which are specific like car , ship, bike etc).
    Hope this claryfies what we need abstract classes for.
    Regards
    Marcin

Maybe you are looking for

  • XML Load Document in EXE does not run

    LV 8.0 (or 8.01). This has got to be a trivial installation problem. I wrote a simple VI that reads in an XML file using the XML Load Document vi. It runs like a charm. I then built an exe. Loading the exe results in the following set of errors: Unab

  • Page formatting is out of whack after comments, new blogs, etc

    I just started my website with iWeb and i'm already having problems. I first noticed this when I added a 7th blog entry and the white background on the blog listing page was not big enough for all the information there, so it shifted to a midpoint...

  • Performa 6500 to G4 PPC data transfer help please

    I now need to recover some files to my current G4 (Leopard) from my old Performa 6500/225 with ethernet but no monitor, no zip, no printer now and read-only CD. Then I will recycle the tower, kb and mouse. If the HD is difficult to remove, should I r

  • 7.0 data flow to 3.x dataflow :(

    I'm curious to see if there are others who are in my situation and want to know how they are coping with it, I have been on 7.0 dataflow from 2005 as part of a ramp up customer and have been on it since then. Now I moved to a new project and this cus

  • RSALOC02 error in OLAP

    We have recently started getting RSALOC02 system errors when running a dataload process. The thread below describes a solution using OWNSPACE but it's an old thread for Express 6.2.0.2. ORACLE EXPRESS SERVER 6.2.0.2 SYSTEM ERROR RSALOC02 Does anyone