aspose file tools*
The moose likes Beginning Java and the fly likes totally screwed newbie, need assignment help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "totally screwed newbie, need assignment help" Watch "totally screwed newbie, need assignment help" New topic
Author

totally screwed newbie, need assignment help

Nick Allen
Ranch Hand

Joined: Sep 25, 2003
Posts: 47
this is my skeleton for my assignment:
import java.io.*;
import java.util.*;

public class Assignment7
{
// declare instance variables

// this method displays the menu options to the user
// the choice should be read in as a String and then converted to an int
// the int should then be returned by this method
public int menu() throws Exception
{



}
// this method should
//1) call the readInUsers() method
//2) provide the menu loop
//3) call the needed methods depending on user choice
public void start() throws Exception
{
readInUsers();
// add in your code here




System.out.println("Thanks for using the system, goodbye");
}

// the constructor of this class, should initialize the instance variables
public Assignment7()
{



}
// this method will ask the user for a filename, and will create a PhoneUser for all users in the file
// and will add this PhoneUser array
public void readInUsers() throws Exception
{
System.out.print("Enter the filename in which the users are stored: ");

// read the filename from the keyboard
String filename=kb.readLine().trim();

// initialize a BufferedReader to read from the file
BufferedReader file=new BufferedReader(new FileReader(filename));
String lineRead=new String();

//read a line from the file
lineRead=file.readLine();

//while text can be read from the file, keep reading
while (lineRead!=null)
{
//the first line is the name of the user
String name=lineRead;
// read another line from the file (department)
String department=file.readLine();
//read another line from the file (phone number)
String phoneString=file.readLine();
// convert the phone number String to an int
int phoneNum=Integer.parseInt(phoneString);

// create a temporary PhoneUser object
// with the values read from the file as
// parameters to the constructor
PhoneUser tempUser=new PhoneUser(name,department,phoneNum);

// add the reference to this user to the array of users
users[numberOfUsers]=tempUser;
// increment the counter that keeps track of how many
// users there currently are in the array
numberOfUsers++;

//read the next line from the file
lineRead=file.readLine();
}
file.close();
}


//below are some suggestions for methods you might want to use



// method receives a String, traverses the array and
// looks for an entry that contains the String in the name field (case insensitve)
// it prints out a message if no user was found
public void findUserByName(String name)
{

}

// method receives an index as a parameter, this index should be a
// valid index in the users array.
// the user is then asked which value should be changed.
// depending on which option is selected, the user will be
// prompted to enter a new name or department
public void changeUserInfo(int index) throws Exception
{

}
// method receives a String, traverses the array and
// looks for an entry that matches the dept String (case insensitve)
// it prints out a message if no user was found
public void findUserByDept(String dept)
{


}

// this method receives a phone number as parameter
// it should return the index in the array of the user that has this
// phone number, or -1 if the user could not be found
public int findUserIndex(int number)
{

}

// this method will print all the users to the screen with the index
// they have in the array
public void listAllUsers()
{

}

public static void main(String[] args) throws Exception
{
Assignment7 a=new Assignment7();
a.start();
}

}
and my user skeleton:
public class PhoneUser
{
// instance variables

//constructor
public PhoneUser(//add parameters here)
{
//use the values sent in as parameters
//to initialize the instance variables
}


// you should add methods that allow external classes to
// - retrieve the class variables
// - assign a new value to the name and department instance variables
// - retrieve all instance variables in tab delimited format (toString() )

}
i realise this is pretty general, i'm gonna keep hacking away at it, but any help will be greatly appreciated with any part of the program.


'I need something good to die for, to make it beautiful to live' -QSA
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
You may want to know that the cowboys and cowgirls at JavaRanch are very conservative when it comes to doing someone's homework. If you have a specific question or problem, we are willing to help. But no one will feed your cattle if you just leave it in the middle of the field.
Aaron Roberts
Ranch Hand

Joined: Sep 10, 2002
Posts: 174
Uhhhhh.... Where is the question? Are you asking if your approach is right? Are you wondering if you should make lots and lots of helper classes? Maybe you are looking to create an innerclass or two?
I'd have to agree with the previous post.
Regards - Dr. A>
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Here's something to play with - about 50% done, I'll leave you to complete it.
Nick Allen
Ranch Hand

Joined: Sep 25, 2003
Posts: 47
Wow, Mike. Thanks alot. I wasn't even hoping for that much help. I got most of those methods sort of working, but your code is a lot cleaner and I didn't think of using that same BufferedReader variable, br, over and over like that, I'm not quite sure why though. That should get me a lot closer to this thing actually getting done though. Thanks man.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: totally screwed newbie, need assignment help
 
Similar Threads
writer's block on assignment, any help?
sorting
assignment help
help please
Lucene beginner question