Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java Phone Book (winnar)
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
.hack




PostPosted: Thu Oct 07, 2004 8:57 am   Post subject: Java Phone Book (winnar)

Hey guys,m you may remember mef rom last year. I'm back in the Grade 12 Java course at my school.

Unfortunately we are using the shittay ready to java compiler from HSA.

Anyways I made a phonebook type thing. Its quite basic. Its simply just a few arrays to store names, phone numbers, cell numbers, addresses and e-mail addresses. I got sick of losing everyones phone numbers and being to lazy to get up from the comp to get a phonebook.

Anyways. This should be released soon, except I am having a problem with outputting my arrays into a text or dat file. I read the examples in the "Introduction to programming in Java" by holtsoft and they don't specify very much.

My main concern is being able to output the text file in a certian directory, All it explains in the book is naming the file, but I didn't see much about placing it into a certain dfirectory, say if I wanted to make an installer later for it.

Is this even possible in Java?
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Thu Oct 07, 2004 1:11 pm   Post subject: (No subject)

anything is posable in java Wink (tho that is in java, not neceraly RTP)

It whould be helpfull to see your code but have you just tryed adding the dir info to the file name?
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
.hack




PostPosted: Thu Oct 14, 2004 8:39 am   Post subject: (No subject)

I can't complete the prog until I learn how to I/O from and to A file. But due to our Ghetto school hiring a math teacher to teach Programming I have been stumped ofr a limited time. Also, my Arrays won't overwrite >.<

Check the code for when you enter a buddy into the phone book and its all Names[1] = klasjaksd or whatever, but when you delete, last I checked you couldn't overwrite the values. Heres the Code.

code:

// The "Phonebook" class.
import java.awt.*;
import hsa.Console;

public class Phonebook
{
    static Console c;           // The output console

    public static void main (String[] args)
    {
        c = new Console ();
        //ARRAYS
        String Names[];
        Names = new String [31];
        String Address[];
        Address = new String [31];
        String CellNum[];
        CellNum = new String [31];
        String Num[];
        Num = new String [31];
        String Email[];
        Email = new String [31];
        String Comment[];
        Comment = new String [31];


        //VARS
        int command;
        int arraynum;
        String YN;
        int iextra;
        iextra = 1;


        //Program

        for (int p = 1 ; p <= 30 ; p = p + 1)
        {
            Names [p] = "Empty";
        } //endfor


        c.println ("Welcome to Buddy Lister v.01b");
        c.println ("The Following are commands To use your Buddy Lister.");
        c.println ("1 -adds a buddy, 2 -Deletes a Buddy, 3 -Change Buddies Info \n 4 -Views a buddies info. 5 -Opens help.");

        while (true)
        {
            c.print ("Enter Command: ");
            command = c.readInt ();

            if (command == 10)
                break;

            switch (command)
            {
                case 1:
                    c.clear ();
                    c.println ("Enter Phone ID To Enter New Buddy Into: ");
                    arraynum = c.readInt ();
                    c.println ("Add Buddies name: ");
                    Names [arraynum] = c.readLine ();
                    c.println ("Add Buddies E-mail address: ");
                    Email [arraynum] = c.readLine ();
                    c.println ("Add Buddies Phone Number: ");
                    Num [arraynum] = c.readLine ();
                    c.println ("Add Buddies Cell Phone Number: ");
                    CellNum [arraynum] = c.readLine ();
                    c.println ("Add A Buddies Address: ");
                    Address [arraynum] = c.readLine ();
                    c.println ("Add A Comment for Buddy: ");
                    Comment [arraynum] = c.readLine ();
                    c.println ();
                    break;

                case 2:
                    c.clear ();
                    c.println ("Enter Buddies Phone ID to Delete: ");
                    arraynum = c.readInt ();
                    c.println ("Are you sure you want to Delete: ");
                    c.println (Names [arraynum]);
                    c.println (Email [arraynum]);
                    c.println (Num [arraynum]);
                    c.println (CellNum [arraynum]);
                    c.println (Address [arraynum]);
                    c.println (Comment [arraynum]);
                    c.println ();
                    c.println ("Y / N");
                    YN = c.readString ();
                    if (YN == "Y" | YN == "y")
                    {
                        Names [arraynum] = "Empty";
                        Email [arraynum] = "Empty";
                        Num [arraynum] = "Empty";
                        CellNum [arraynum] = "Empty";
                        Comment [arraynum] = "Empty";
                        Address [arraynum] = "Empty";
                    }
                    else
                    {
                        c.print ("");
                    }
                    break;

                case 3:
                    c.clear ();
                    c.println ("Enter Buddies Phone ID To Change: ");
                    arraynum = c.readInt ();
                    c.println ("Enter Buddies New Name: ");
                    Names [arraynum] = c.readLine ();
                    c.println ("Enter Buddies New E-mail Address: ");
                    Email [arraynum] = c.readLine ();
                    c.println ("Enter Buddies New Phone Number: ");
                    Num [arraynum] = c.readLine ();
                    c.println ("Enter Buddies New Cell Phone Number: ");
                    c.println ("Enter Buddies New Address: ");
                    Address [arraynum] = c.readLine ();
                    c.println ("Enter A New Comment For Buddy: ");
                    Comment [arraynum] = c.readLine ();
                    break;

                case 4:
                    c.clear ();
                    c.println ("Enter Phone ID to View: ");
                    arraynum = c.readInt ();
                    c.println ("Phone ID : " + arraynum);
                    c.println ("Name : " + Names [arraynum]);
                    c.println ("E-mail : " + Email [arraynum]);
                    c.println ("Phone Number : " + Num [arraynum]);
                    c.println ("Cell Phone Number : " + CellNum [arraynum]);
                    c.println ("Address : " + Address [arraynum]);
                    c.println ("Comment : " + Comment [arraynum]);
                    break;

                case 5:
                    c.clear ();
                    for (int i = 1 ; i <= 30 ; i = i + 1)
                    {
                        c.println ("ID: " + i + " Name: " + Names [i]);

                    } //endfor

                case 6:
                    c.clear ();
                    c.println ("1 -adds a buddy, 2 -Deletes a Buddy, 3 -Change Buddies Info \n 4 -Views a buddies info.5 -Opens Directory. 6 -Opens help.");
                    c.println ("");
                    c.println ("Any bugs or problems found Contact Ph34revolved@hotmail.com. Or \n on IRC: SERVER: Gamesurge, Channel: #ikonz. PM Ephekt.");
                    break;
            }
        }
    } // main method
} // Phonebook class
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: