You are to create two classes to implement a database program. The main class is a menu of options and will create an arraylist() to store the objects. The other object contains the data that will be stored in the array list
Data Class
You are to create a class that implements the comparable interface and stores data. It is similar to the contact method in the book. It should have the following methods:
- A constructor method
- A get() and set() for each data element
- String toString()
- int compareto(object)
For example, if the class was a ASU_student, you might have a student id, first and last names, and a debt. Then you would have:
- void ASU_student( id, first, last, debt)
- String getid(), String getfirst(), String getlast(), double getdebt()
- void setid( id), void setfirst( first), void setlast( last), void setdebt( debt)
- String toString()
- int compareto( obj);
Main Class
In this class, you will create an arraylist to store objects of the above Data Class. This class will prompt the user, via a menu, to perform the following operations, until the user decides to quit.
1. Add an object to the list – the object should be unique. Thus, you will need to search the list before adding to make sure the Key is not already there. The key can be any data item (ex. student id), or combination of data items (Band + CD).
2. Display an object from the list. Ask for the key, search, and display all the data for the object, or that it was not found
3. Remove an object from the list. Ask for the key, search, and if there remove it.
4. Modify an object from the list. Ask for the key, search, and update the non-key fields.
5. Scan the database for some sub-information, or non-key fields. For example, you may want to display all records with a certain last name, or CD name, or range of GPA, ...
As Extra Credit, try reading in the database from a text file when the program starts, and saving it to a text file as the program exits.
Look at the book examples and the on-line documentation to see how an arraylist is used.
Name:
Anonymous2006-04-04 19:53 (sage)
>>1
Translated:
HAI. HALP ME DO MY HOMEWRK. LOLOL. KTHXBAI.
Name:
Anonymous2006-04-04 21:01
As a marker I can tell you that we appreciate it if you don't hand anything in.
>>1 It should have the following methods: A get() and set() for each data element
And what the fuck are those "data elements"? My 8-ball is broken, I would help but I'm not a fucking wizard...
Name:
Anonymous2006-04-06 20:53 (sage)
I love how he doesn't even include a message asking for help. Gets right to the point. In fact, it's as if he were assigning this homework to us.
Not to mention the fact that a 12 year old retard could figure this out by himself while crying from being slapped around by his abusive alcoholic father.
>>13 Helping you with programming does not mean doing your homework for you.
Name:
Anonymous2006-04-07 6:59 (sage)
>>13
Asking for homework help is widely considered unacceptable, not just on world4ch. Just try doing it in an IRC channel like ##java on irc.freenode.net; they will yell at you like you ate their testicles.
Name:
Anonymous2006-04-07 12:57
>>16
And what is this place supposed to be if not to help each other? Language flamewars between Ruby and Python? I'd like to help >>1 but I don't even understand what his problem is.
Name:
Anonymous2006-04-07 19:29
Here is the solution for the first class: class Data implements Comparable
{
public Data() { }
public int get() { return 42; }
public void set(int i) { /* I don't care, I prefer 42 */ }
public String toString() { return "Hello, world!"; }
public int compareTo(Object o) { return 666; }
}Maybe you can be more precise next time. Why don't you scan your assignment and put it on ImageShack, maybe I can help a bit.
Name:
Anonymous2006-04-07 19:33
>>17
No sir. This forum is supposed to be an ongoing flamewar between Perl, PHP, Ruby, Python, Lisp, Scheme, C, VB, and many other languages. We'll agree to one thing though - Java sucks.
In a few years, you'll realised that >>1 will turn out to be your co-worker or new manager, and that somehow got a BSc Degree and knows shit little about basic programming.
I'm sure you'll be ESCATIC to find out that you helped someone who can't even implement a simple OO Object defination get that degree.
We, people who perhaps code for a living, on a whole, thank you for putting cut and paste "coders" through university.
I code for a living and I'm not >>20, so there must be at least two people coding for a living here. And the best of all: it doesn't imply Java. This keeps me happy.
Name:
Anonymous2006-04-08 7:58
>>23
No because >>20 was lying, you're the only one coding for a living here unless you're a troll too.
Name:
Anonymous2006-04-08 8:30
>>24
Just because you are a troll, doesn't mean everyone else is.
Name:
Anonymous2006-04-08 8:49
I hate Java, but do your own fucking homework.
Name:
Anonymous2006-04-08 13:56
sigh. i teach and code java for a living. you all suck. except >>18 for spending 2 seconds of his/her life helping a student that should be failing.
>>10
i would be guessing data elements would be instance variables.
you just suck though.
Name:
Anonymous2006-11-19 14:03
>>30
Give a man a fire and he'll be warm for the rest of the day, put the man on fire and he'll be warm for the rest of his life.
Name:
Anonymous2006-11-19 15:33
Okay, so someone is being held over a pit of lava and we have to cool off the lava before we get him loose. Okay! Let's call on Iceman!
Hmm? No? Iceman's powers have no effect on lava? Oh well, I guess we'll have to find a cauldron to pour on the lava! Okay, Iceman, you're off the hook, lukewarm water has saved the day!
The same applies to when you find someone trapped in a block of ice - can the Human Torch or Ghost Rider melt it? No. But you know what can? THE INDIRECT RAYS OF THE SUN.
The logic, it breaks. There's even a part of the game where they say "USE SOMEONE'S LIGHTNING POWERS" and when you do, it works. Simple as that. So why not make ice powers, you know, have icy effects?
>>39
God, I remember when I used to see that shitty spam daily. Not just here, but even places like Slashdot. Can't imagine anybody ever thought that was funny. And newfags try to pretend the internet used to be good.