Hi guys, i've currently got an assignment, whereby, im supposed to create 2 classes, a Vehicle superclass, and a Taxi subclass.
Vehicle class needs to have Reg Number, model, price, and Taxi is supposed to inherit those from it.
I have done so, but now, it requires that all the data be stored in an array.
The final program, should be able to :
1) Add new taxi's into the program (which retains even after program exit)
2) Search for a particular taxi based on the given data
3) Display average price of the taxi.
My question is,
Should i store all the data in a database and read it from an array?
or
Store the data in a text file, and read the data from the array.
if i shud store the data in a database and read em from the array, how? i've read up on the JDBC introduction, i can have a MYSQL database in place, but whats the code for the array to read the data from database.
else
I've tried storing the data in text files, and reading it, but problem is, whenever i add a new entry into the text file, it doesnt just insert a new line of entry at the bottom of the txt file, but instead it overrides the old txt file thus losing all records.
Example of how the program should be like :
Please make a selection :
1) Add a new Taxi?
2) Search for old Taxi?
3) Display list of taxi in records?
4) Display average price of taxi?
5) Terminate the program
Enter Input :
------------- The List of Taxi -----------------------------------------------
Reg Num. Model Price TaxiCompany
------------------------------------------------------------------------------------
NY2314 Mercedes 20,000 ABC Company
DC1341 Volvo 15,000 DEF Company
TX5552 Ford 19,000 LJK Company
6 2037
I've tried storing the data in text files, and reading it, but problem is, whenever i add a new entry into the text file, it doesnt just insert a new line of entry at the bottom of the txt file, but instead it overrides the old txt file thus losing all records.
did you open the file with append set true so new data would be added on the end of the file?
did you open the file with append set true so new data would be added on the end of the file?
um nope? im not exactly all so good with java, as i just started learning, and our lecturer already expects us to be able to do all this stuff, when we only just finished the chapter on inheritance. as for the code to save to file, i got it from googling around.
hm, as for arrays, is it possible to read lots of data from a database? as in, many fields? i was thinking like 4 fields (price, model, reg num, speed) = a 4 dimensional array? or ?
whats the best way to approach this using arrays as its a req for the assignment
I'm still thinking of how i'm gonna output as well as input all these data into an array.
thanks for the reply/
um nope? im not exactly all so good with java, as i just started learning, and our lecturer already expects us to be able to do all this stuff, when we only just finished the chapter on inheritance. as for the code to save to file, i got it from googling around.
hm, as for arrays, is it possible to read lots of data from a database? as in, many fields? i was thinking like 4 fields (price, model, reg num, speed) = a 4 dimensional array? or ?
whats the best way to approach this using arrays as its a req for the assignment
I\\\'m still thinking of how i\\\'m gonna output as well as input all these data into an array.
thanks for the reply/
You don\\\'t need a 4d array. You use the classes that you wrote for temporary store of the values when retrieving the data from the file or from the database. First, howver, decide on whether you want to use a database or a file(The choice depends on your knowledge of these things so far.) If you decisde to use a file, you should serialize your classes so you can store whole objects of them.
You don\\\'t need a 4d array. You use the classes that you wrote for temporary store of the values when retrieving the data from the file or from the database. First, howver, decide on whether you want to use a database or a file(The choice depends on your knowledge of these things so far.) If you decisde to use a file, you should serialize your classes so you can store whole objects of them.
i see, hm, im thinking of a database, seeming that reading from a file seemed to prove much problems when writing to the file for me, as well as the problem of reading. is there any where i can get more knowledge on those databases as well as code examples and explanations besides from the java.sun website? thanks again for the reply
i see, hm, im thinking of a database, seeming that reading from a file seemed to prove much problems when writing to the file for me, as well as the problem of reading. is there any where i can get more knowledge on those databases as well as code examples and explanations besides from the java.sun website? thanks again for the reply
If you are covering them in class that should not be a problem, you can always ask any questions here if you get any problems. However, if you haven't been introduced to jdbc in class yet then you might as well use the file option for this exercise.
If you are covering them in class that should not be a problem, you can always ask any questions here if you get any problems. However, if you haven't been introduced to jdbc in class yet then you might as well use the file option for this exercise.
well, uh the problem is, im doing e-study, which is fully online based, and apparently, we arent being taught much -.- neither do the course content has anything regarding reading/writing from/to files. which is actually the reason why im posting here. we're expected to do something that we arent even taught. and yea, we're not covering any of the above in class, only classes, inheritance, basic logical exp, so far.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JShurmatz |
last post by:
If anyone can shed some light on this problem I would greatly
appreciate it.
I am unsuccessfully trying to use a database connnection retrieved
from a pool configured using Java System Web...
|
by: jdavis999x |
last post by:
I have spent a good deal of time looking for how to connect an applet
to a remote database (MS Access) using JDBC, as yet I have found no
solid solution!!
According to some books I have read the...
|
by: Raquel |
last post by:
Is anyone aware of a website/documentation which has a one to one
comparision of corresponding programming features available in JDBC Vs
SQLj. For example:
CONCURRENCY:
- JDBC: set through...
|
by: sid_mulpuru |
last post by:
I am trying to read data from a DB2 Blob Data type Field (using wsad
5.1.0) using getBlob() which when executed
gives an SQL Exception
2005-01-07 15:48:40,506
ERROR - Error in...
|
by: kommaraju |
last post by:
iam a starter to db2 & jdbc.i have a servlet program which connects to ibm db2
using jdbc.when i run this using apache tomcat 4.1.34 , it is showing a
error message of HTTP STATUS 500
my jdbc...
|
by: yksoni |
last post by:
we are working in IBM aglets 2.0.2 with mysql 4.0.2.
When we try to access database through tahiti server i.e.aglets we get following error.
java.net.SocketException
MESSAGE:...
|
by: byahne |
last post by:
We just went live today with a production SQL Server 2005 database
running with our custom Java application. We are utilizing the jTDS
open source driver. We migrated our existing application...
|
by: Anoop |
last post by:
Is it true that there are no type 4 jdbc drivers to connect to a DB2
server v7.1? The DB2 server is hosted on ACF2 (OS/390). We would be
connecting from windows and solaris boxes.
If it is true,...
|
by: anokun7 |
last post by:
Hi,
I am connecting to a DB2 v7.1 server from windows using JDBC type 2 (I
figured out that type 4 is only for 8 and upwards).
I used DB2 Connect to create a system DSN and seem to be able to...
|
by: neuraljay |
last post by:
hi everyone. I am trying to build a jsp using webwork, hibernate and mysql. And right now I am doing its unit testing. Everytime I run the test I am getting this error:
Error JDBC exception on...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |