Results 1 to 3 of 3
  1. #1
    Madz is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

    Unhappy need help with package renaming

    Java Code:
    /
    import java.io.*;
    import displayall.*;
    
    class input
    {
    	public String nama;
    	public int x, total, price, i=1;
    
    	void snama () throws IOException
    	{
    		BufferedReader name = new BufferedReader (new InputStreamReader (System.in));
    		System.out.print ("Masukkan nama organisasi atau syarikat "+i+": ");
    		nama = name.readLine ();
    		i++;
    	}
    
    	void pUbah (int xx1, int xtotal1)
    	{
    		x = xx1;
    		
    		total = xtotal1;
    		
    		
    	}
    
    	void iteminput () throws IOException
    	{
    		String str;
    		int set, kt, num;
    		do
    		{
    			BufferedReader item = new BufferedReader (new InputStreamReader (System.in));
    			System.out.print ("Masukkan kod item: ");
    			str = item.readLine ();
    			set = Integer.parseInt (str);
    			switch (set)
    			{
    				case 1:
    				price = 99;
    				
    				break;
    				case 2:
    				price = 150;
    				
    				break;
    				case 3:
    				price = 140;
    				
    				break;
    				case 4:
    				price = 80;
    				
    				break;
    				default:
    				System.out.println ("Kod item salah, sila masukkan sekali lagi.");
    			}
    			if ((set == 1) || (set == 2) || (set == 3) || (set == 4))
    			{
    				System.out.print ("Masukkan kuantiti: ");
    				str = item.readLine ();
    				kt = Integer.parseInt (str);
    				try
    				{
    					if (kt <= 0)
    					{
    						throw new Exception ("Kuantiti yang salah.");
    					}
    					total = kt * price + x;
    					x = total;
    					
    					
    				}
    
    				catch (Exception a)
    				{
    					System.out.println (a.getMessage ());
    				}
    			}
                            System.out.println("\nHarga: RM"+total+".00" );
    			System.out.print ("\nIngin tambah item? (Ya = 1/Tidak = 2): ");
    			str = item.readLine ();
    			num = Integer.parseInt (str);
    		} while (num == 1);
    	}
    }
    
    class kira extends input
    {
    	int temp1 = 0, temp2 = 0, dif = 0;	
    
    	void kirahargasel ()
    	{
    		temp1 = total + temp1;
    		
    	}
    }
    
    class papar extends kira
    {
    	void paparnama ()
    	{
    		System.out.println ("Nama organisasi atau syarikat  : " + nama);
    	}
    
    	void paparjumlah ()
    	{
    		System.out.println ("Jumlah jualan  : RM " + total + ".00");
    		
    	}
    
    	void paparjumsel ()
    	{
    		System.out.println ("Jumlah keseluruhan jualan: RM " + temp1 + ".00");
    		
    	}
    }
    
    class totalearn
    {
    	public static void main (String args []) throws IOException
    	{
    		BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
    		String str1;
    		int num1;
    
    		displayall obj1 = new displayall ();
    		papar obj2 = new papar ();
    		obj1.paparintro ();
    		do
    		{
    			obj1.paparitem ();
    			obj2.snama ();
    			obj2.pUbah (0, 0);
    			obj2.iteminput ();
    			obj1.paparjumlah ();
    			obj2.paparnama ();
    			obj2.paparjumlah ();
    			obj2.kirahargasel ();
    			System.out.print ("\nKeluar dan paparkan keseluruhan jumlah jualan? (Ya = 1/Tidak = 2): ");
    			str1 = stdin.readLine ();
    			num1 = Integer.parseInt (str1);
    		} while (num1 == 2);
    		obj1.paparsel ();
    		obj2.paparjumsel ();
    		paparakhir ();
    	}
    
    	static void paparakhir ()
    	{
    		StringBuffer sa = new StringBuffer (".TAMAT METSIS");
    		sa.reverse ();
                    System.out.println ("\n\t\t\t\t" + sa);
    		char word [] = {'T', 'E', 'R', 'I', 'M', 'A', ' ', 'K', 'A', 'S', 'I', 'H', '.'};
    		String as = new String (word);
    		System.out.println ("\t\t\t\t" + as);
    	}
    }

    Java Code:
    package displayall;
    
    public class displayall
    {
    
    	public void paparintro ()
    	{
                    System.out.println ("\n\t\t********************************");
    		String s = new String ("\t\t|  Sistem Jualan Alatan Sukan  |");
    		String str = s.toUpperCase ();
    		System.out.println (str);
                    System.out.println ("\t\t********************************");
    	}
    
    	public void paparitem ()
    	{
    		System.out.println ("\n**************************************************************************");
    		System.out.println ("| Kod Item\t Alatan Sukan\t   Jenama\t\tHarga    |");
                    System.out.println ("--------------------------------------------------------------------------");
    		System.out.println ("| 1\t\tBola Sepak\t     Adidas\t\tRM 99.00 |");
    		System.out.println ("| 2\t\tBola Keranjang\t Spalding\t      RM 150.00|");
    		System.out.println ("| 3\t\tRaket Badminton\tYonex\t\t RM 140.00|");
    		System.out.println ("| 4\t\tKayu Hoki\t      Reebok\t\tRM 80.00 |");
    		System.out.println ("**************************************************************************\n");
    	}
    
    	public void paparjumlah ()
    	{
    		System.out.println ("\n******************************");
    		System.out.println ("|        Jumlah Jualan       |");
    		System.out.println ("******************************\n");
    	}
    
    	public void paparsel ()
    	{
    		System.out.println ("\n*********************************");
    		System.out.println ("|  Jumalah Keseluruhan Jualan    |");
    		System.out.println ("*********************************\n");
    	}
    }

    i want to rename the package name from "display" to "papar" but there are errors.... and also I need to change the class name from "totalearn" to "sistem"... help me pls...

  2. #2
    Swamipsn is offline Member
    Join Date
    Jul 2007
    Posts
    74
    Rep Power
    0

    Default

    Could you teel us the propblem bit more? Use Eclipse, so that you can refactor name without any trouble

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    Changing the class name isn't a problem. It just means you have to find everywhere that class is used and rename it in those locations as well.

    Changing the package name involves also changing the name of the directory the java file is located in, as well as changing the name everywhere it is used in the code.

    By the way, the Java naming standard is to have class names start with a Capital letter.

Similar Threads

  1. Replies: 7
    Last Post: 11-09-2009, 07:51 AM
  2. Renaming underlying directory in Java project
    By Rodrigo Braz in forum Eclipse
    Replies: 3
    Last Post: 03-08-2009, 07:25 AM
  3. Renaming a method/variable
    By gapper in forum Eclipse
    Replies: 0
    Last Post: 01-31-2008, 01:29 PM
  4. Renaming a class
    By mew in forum Eclipse
    Replies: 2
    Last Post: 12-06-2007, 11:29 PM
  5. Renaming a class in Eclipse
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-04-2007, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •