Results 1 to 3 of 3
Thread: need help with package renaming
- 11-24-2009, 08:51 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
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...
- 11-25-2009, 06:48 AM #2
Member
- Join Date
- Jul 2007
- Posts
- 74
- Rep Power
- 0
Could you teel us the propblem bit more? Use Eclipse, so that you can refactor name without any trouble
- 11-25-2009, 09:39 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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
-
The declared package does not match the expected package
By oneforall in forum EclipseReplies: 7Last Post: 11-09-2009, 07:51 AM -
Renaming underlying directory in Java project
By Rodrigo Braz in forum EclipseReplies: 3Last Post: 03-08-2009, 07:25 AM -
Renaming a method/variable
By gapper in forum EclipseReplies: 0Last Post: 01-31-2008, 01:29 PM -
Renaming a class
By mew in forum EclipseReplies: 2Last Post: 12-06-2007, 11:29 PM -
Renaming a class in Eclipse
By Java Tip in forum Java TipReplies: 0Last Post: 12-04-2007, 10:54 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks