最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - code does not compile when i create an object from another class - Stack Overflow

programmeradmin1浏览0评论

so I have an small project of two classes, CCuenta.java and Test.java(main) and it gives me an error when I create CCuenta obj.

so I put some images with my code hoping you can tell me why it does not runs, IDK if its something related with the code

this is an small test project and i want to know why is not running before I keep entering code and other classes

please help

project

main


package com.mycompanyuenta;
import com.mycompanyuenta.CCuenta;

/**
 *
 * @author tony
 */
public class Test {
    
    public static void main(String[] args)
    {
        CCuenta cuenta01 = new CCuenta();
  
        
        cuenta01.asignarNombre("Un nombre"); 
        cuenta01.asignarCuenta("Una cuenta");
        cuenta01.asignarTasaDeInteres(2.5);
        
        cuenta01.deposito(12000);
        cuenta01.retiro(3000);
        
        System.out.println(cuenta01.obtenerNombre());
        System.out.println(cuenta01.obtenerCuenta());
        System.out.println(cuenta01.estado());
        System.out.println(cuenta01.obtenerTasaDeInteres());
        
    }
    
}  

obj

package com.mycompanyuenta;

/**
 *
 * @author tony
 */
class CCuenta
{

        private String nombre;
        private String cuenta; 
        private double saldo;
        private double tazaDeInteres;
        
        public void asignarNombre(String nom)
        {
            if (nom.length() == 0)
            {
                System.out.println("Error: cadena vacia");
                return;   
            }
            
            nombre = nom;
        }        
        
        public String obtenerNombre()
        {
        return nombre;
        }
                
        
        public double estado()
        {
        
        return saldo;
        }        
        
        public void asignarCuenta(String cue)
        {
            if (cue.length() == 0)
            {
                System.out.println("cuenta no valida");
                return;
            }
            cuenta = cue;     
        
        }
        
        public String obtenerCuenta()
        {
            
        return cuenta;
        }
                
        public double saldo()
        {
            return saldo; 
        
        }        
        
        public void deposito(double cantidad)
        {
                if(cantidad < 0)
                {
                     
                    System.out.println("Error: cantidad negativa");
                    return;
                    
                }
                saldo = saldo + cantidad;
        }        
           
        public void retiro(double cantidad)
        {
                if(saldo - cantidad < 0)
                {
                    System.out.println("no dispone de saldo suficiente");
                    return;
                
                }
                saldo = saldo - cantidad;
        
        }      
        
        public void asignarTasaDeInteres(double taza)        
        {
                if(taza < 0)
                {
                    System.out.println("Error: tasa de interes no valida");
                    return;
                
                }
                
                tazaDeInteres = taza;
        }
                
           
        public double obtenerTasaDeInteres()
        {
            return tazaDeInteres; 
        
        }        
        
        
        
}

error

Error: Main method not found in class com.mycompanyuenta.CCuenta, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
发布评论

评论列表(0)

  1. 暂无评论