tag:blogger.com,1999:blog-7774229.post115205253593739346..comments2008-03-29T17:21:47.277-07:00Comments on Space Program Blog: Db4oUtil (aka. The Easiest Way to Get Started With...Travis Reedernoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7774229.post-81314384663403572862008-03-29T17:21:00.000-07:002008-03-29T17:21:00.000-07:002008-03-29T17:21:00.000-07:00i need a code for space ,planet program im giving ...i need a code for space ,planet program<BR/> im giving the specification<BR/><BR/>Intermediate Object-Oriented Programming<BR/>Assignment - Semester 1, 2008<BR/>Due Date: 9.30am 7th April 2008<BR/>Delays caused by computer downtime cannot be accepted as a valid reason for a late submission without penalty. Students must plan their work to allow for both scheduled and unscheduled downtime.<BR/>Submission Details<BR/>You must submit an electronic version of your assignment on latcs6 using the submit command. Ensure you submit all required files. Files should be submitted one file at a time. For example, the file SpaceProgram.java would be submitted with the command:<BR/> > submit IOO SpaceProgram.java<BR/>This is an individual Assignment. You are not permitted to work as a group when writing this assignment.<BR/>Copying, Plagiarism: Plagiarism is the submission of somebody else’s work in a manner that gives the impression that the work is your own. The Department of Computer Science and Computer Engineering treats plagiarism very seriously. When it is detected, penalties are strictly imposed. Refer to the unit guide for further information and strategies you can employ to avoid a charge of academic misconduct. All reports and source code will be electronically checked for plagiarism.<BR/>Return of Assignment: You will receive a marking sheet with a mark break down within three weeks of submission.<BR/>Please Note: While you are free to develop the code for this assignment on any operating system, your solution must run on the latcs6 system. <BR/>Assignment Objectives<BR/>• To analyse, a problem in an object-oriented manner, and then design and implement an object-oriented solution<BR/>• To practise using inheritance in Java.<BR/> <BR/>Problem Description<BR/><BR/>Samantha is an amateur astronomer who likes to view and record the celestial bodies she observes through her telescope. She would like to have a program that allows her to keep information about what she observes and to query the system to find out interesting facts such as which of the stars she has recorded is the furthest away from earth, or which of the celestial bodies she has seen is the largest.<BR/><BR/>She has already started to keep some facts in a file about the stars, planets, dwarf planets and moons she has seen. Your job is to write a program to read these facts from a file and provide a user interface to add and edit the information stored. You will also provide some query facilities to answer questions that interest Samantha.<BR/><BR/>Stars<BR/><BR/>Stars are stored in the file over 6 lines. For example:<BR/> <BR/>Star <BR/>Altair <BR/>1.7 <BR/>A <BR/>IV <BR/>16.73 <BR/><BR/>• The first line of every entry is the type of the celestial object, in this case Star.<BR/>• The second line is the name of the star which may be one or more words.<BR/>• The third line is the radius of the star expressed in solar radius units. One solar radius is approximately 695,500 km. <BR/>• The fourth line is the spectral type. This classification is based on the colour of the star (its spectrum).<BR/>Class O – blue<BR/>Class B – blue white<BR/>Class A – white<BR/>Class F – yellowish white <BR/>Class G – yellow<BR/>Class K – orange<BR/>Class M – red<BR/>Class W – superluminous blue<BR/>Class L – dark red<BR/>Class T – cool brown dwarf<BR/>Class Y – ultra cool brown dwarf<BR/>Class C – carbon star<BR/>Class S – between a class M and carbon star<BR/>Class D – white dwarf<BR/> <BR/><BR/>• The fifth line is the basic Yerkes spectral classification. This is a classification based on the luminosity of the star. There are seven possible values.<BR/>I – supergiants<BR/>II – bright giants<BR/>III – normal giants<BR/>IV – subgiants<BR/>V – dwarfs<BR/>VI – subdwarfs<BR/>VII - white dwarfs<BR/><BR/>• The sixth line is how far away the star is. The measurement is given in light years.<BR/><BR/><BR/>Planets<BR/><BR/>For planets the information is stored on 6 lines. For example:<BR/><BR/>Planet<BR/>Neptune<BR/>24764.0<BR/>1.0243 26 <BR/>60190.0<BR/>48<BR/><BR/>• The first line of every entry is the type of the celestial object, in this case Planet.<BR/>• The second line is the name of the planet which may be one or more words.<BR/>• The third line is the radius of the planet expressed in kilometres. <BR/>• The fourth line is the mass of the planet in kilograms. This line contains the mantissa and exponent of the planet’s mass expressed in scientific notation. For example, for the planet Neptune the mass of the planet is 1.0243 x 1026kg<BR/>• The fifth line is the orbital period of the planet in days. This is how long it takes for the planet to orbit their star.<BR/>• The sixth line is the temperature of the planet in degrees Kelvin.<BR/><BR/>Dwarf Planets<BR/><BR/>Dwarf planets are like planets in that they are also natural satellites of a star, but they are not big enough to be classified as planets, but are larger than asteroids.<BR/><BR/>For Dwarf Planets the information takes 5 lines. For example:<BR/><BR/>DwarfPlanet<BR/>Ceres<BR/>480<BR/>9.43 20<BR/>167<BR/><BR/>• The first line is the type of the celestial object, in this case DwarfPlanet.<BR/>• The second line is the name of the dwarf planet which may be one or more words.<BR/>• The third line is the radius of the dwarf planet expressed in kilometres. <BR/>• The fourth line is the mass of the dwarf planet in kilograms. This line contains the mantissa and exponent of the dwarf planet’s mass expressed in scientific notation.<BR/>• The fifth line is the temperature of the dwarf planet in degrees Kelvin.<BR/><BR/><BR/>Moons<BR/><BR/>Information about moons is stored over 6 lines. For example:<BR/><BR/>Moon<BR/>Ganymede<BR/>2634.1<BR/>1.4819 23<BR/>Jupiter<BR/>110<BR/><BR/>• The first line is the type of the celestial object, in this case Moon.<BR/>• The second line is the name of the moon which may be one or more words.<BR/>• The third line is the radius of the moon expressed in kilometres. <BR/>• The fourth line is the mass of the moon in kilograms. This line contains the mantissa and exponent of the moon’s mass expressed in scientific notation.<BR/>• The fifth line is the name of the planet or dwarf planet that the moon orbits (i.e. the moon is a satellite of the planet or dwarf planet).<BR/>• The sixth line is the temperature of the moon in degrees Kelvin.<BR/><BR/><BR/>Unknown Values<BR/><BR/>In the data files, if a numeric value was not known a -1 was entered.<BR/>If a string or character value was not known a hyphen ‘-‘ was entered. <BR/>Task 1<BR/><BR/>Design and implement a class hierarchy to represent the celestial objects in this program.<BR/><BR/>Consider whether any methods or classes should be abstract.<BR/><BR/><BR/>Task 2<BR/><BR/>Write a menu-based system that repeatedly asks the user what task they would like to do and then carries out that task. The menu should look as follows:<BR/><BR/>------------------------------------------------<BR/>A - load from file<BR/>B - display to screen<BR/>C - add a new space body<BR/>D - write to file<BR/>E - display by size<BR/>F - display by name<BR/>G - display moons of planet/dwarf planet<BR/>H - display all space bodies in temperature range<BR/>I - display a given space body<BR/>J – display largest space body<BR/>K – display smallest space body<BR/>L – display most distant object<BR/>M - exit program<BR/>------------------------------------------------<BR/><BR/><BR/>Task 3<BR/><BR/>Implement the required functionality of each menu option:<BR/><BR/><BR/>A) Load from file<BR/><BR/>Ask the user for the name of a text file containing information about celestial objects, then load the information stored in that file.<BR/><BR/>If the file does not exist then a warning message must be displayed and the program goes back to the menu.<BR/><BR/><BR/> <BR/>B) Display to screen<BR/><BR/>Displays all the space bodies stored in the system to screen. Each space body should be formatted as in the following examples:<BR/><BR/>Star: Achernar<BR/> spectral type = C<BR/> classification = V<BR/> radius = 10.0 solar radii<BR/> distance = 144.0 ly<BR/><BR/>Moon: Charon<BR/> radius = 603.5 km<BR/> mass = 1.52 x 10^21 kg<BR/> temp = 53.0 K<BR/> satellite of Pluto<BR/><BR/>DwarfPlanet: Eris<BR/> radius = 1300.0 km<BR/> mass = 1.67 x 10^22 kg<BR/> temp = 42.0 K<BR/><BR/>Planet: Mars<BR/> radius = 3396.0 km<BR/> mass = 6.4185 x 10^23 kg<BR/> temp = 227.0 K<BR/> orbital period = 686.971 days<BR/><BR/><BR/>C) Add a new space body<BR/><BR/>This should prompt the user for the type of a new object to add, and then, depending on the type they enter, prompt for values for the appropriate fields. For example:<BR/><BR/>Add a Star, Planet, DwarfPlanet or Moon? star<BR/>Enter the name of the Star: Achernar<BR/>Enter the radius: 10<BR/>Enter the type: C<BR/>Enter the classification: V<BR/>Enter the distance: 144<BR/><BR/><BR/><BR/>D) Write to file<BR/><BR/>Ask the user for the name of a text file to write information to then write the information to the file in the format initially used.<BR/><BR/>If the file cannot be created then a warning message must be displayed and the program goes back to the menu.<BR/><BR/> <BR/><BR/>E) Display by size<BR/><BR/>Display all the objects in descending order of size (based on radius). If an object has a negative radius recorded, indicating an unknown value, it shouldn’t be displayed. Use the format given in part B) for each object displayed.<BR/><BR/><BR/>F) Display by name<BR/><BR/>Display all the objects in ascending alphabetical order. The ordering should be case insensitive. Use the format given in part B) for each object displayed.<BR/><BR/><BR/>G) Display moons of planet/dwarf planet<BR/><BR/>Ask the user for the name of a planet or dwarf planet and then display all the moons of it. Use the format given in part B) for each moon displayed.<BR/><BR/><BR/>H) Display space body in temperature range<BR/><BR/>Asks the user to enter the minimum and maximum temperature in Kelvin and then displays the type, name and temperature of all space objects with temperatures between those values. For example:<BR/><BR/>Enter minimum temp in Kelvin: 60<BR/>Enter maximum temp in Kelvin: 230<BR/>Planet - Mars - 227.0 K<BR/>Planet - Jupiter - 120.0 K<BR/>Moon - Europa - 103.0 K<BR/>Planet - Saturn - 88.0 K<BR/>DwarfPlanet - Ceres - 167.0 K<BR/>Moon - Ganymede - 110.0 K<BR/>Moon - Callisto - 134.0 K<BR/>Moon - Io - 130.0 K<BR/>Moon - Titan - 93.7 K<BR/>Moon - Rhea - 76.0 K<BR/>Moon - Titania - 60.0 K<BR/>Moon - Oberon - 61.0 K<BR/>Moon - Iapetus - 100.0 K<BR/> <BR/><BR/>I) Display a given space body<BR/><BR/>Ask the user for the name of a space body and display all the information about the space body with that name using the format given in part B). If no space body with that name exists in the system, a warning should be given to the user and control returned to the menu.<BR/><BR/><BR/>J) Display largest space body<BR/><BR/>Display the space body in the system with the largest radius using the format shown in part B).<BR/>.<BR/><BR/>K) Display smallest space body<BR/><BR/>Display the space body in the system with the smallest radius using the format shown in part B)<BR/><BR/><BR/>L) Display most distant object<BR/><BR/>Display the object in the system that is furthest away (has the greatest distance) using the format shown in part B).<BR/><BR/><BR/><BR/>For all tasks<BR/>You may assume that the user always inputs correctly at the keyboard and that the file is in the correct format. You should however catch the exceptions that may be generated by the opening of files within the program.<BR/><BR/> <BR/>Submission requirements<BR/><BR/>Assignments are to be submitted electronically on latcs6. You must submit all .java files. The program must be able to be compiled with the command<BR/> javac *.java<BR/>and run with the command<BR/> java SpaceProgram<BR/>There is a sample initial file in the directory ~csilib/cse1ioo/assignment for you to start with.<BR/><BR/>The marking scheme is as follows:<BR/>Task 1 – 15%<BR/>Marks are awarded here for the design and implementation of an appropriate class hierarchy. While this percentage is not high a good hierarchy design will make the tasks in part 3 significantly easier.<BR/><BR/>Task 2 – 10%<BR/>Marks are awarded here for a correctly functioning menu system.<BR/><BR/>Task 3 – 75%<BR/>Marks are awarded here for correctly functioning menu options. <BR/>A - load from file (10%)<BR/>B - display to screen (5%)<BR/>C - add a new space body (10%)<BR/>D - write to file (5%)<BR/>E - display by size (8%)<BR/>F - display by name (5%)<BR/>G - display moons of planet/dwarf planet (5%)<BR/>H - display space body in temperature range (5%)<BR/>I - display a given space body (5%)<BR/>J - display largest space body (5%)<BR/>K - display smallest space body (5%)<BR/>L - display most distant object (5%)<BR/>M - exit program (2%)<BR/><BR/><BR/>This assignment constitutes 10% of your overall mark in CSE1IOO.mittapallisanthoshhttp://www.blogger.com/profile/01286222970603407184noreply@blogger.comtag:blogger.com,1999:blog-7774229.post-1159231412428409602006-09-25T17:43:00.000-07:002006-09-25T17:43:00.000-07:002006-09-25T17:43:00.000-07:00Marko, you will get the same ObjectContainer in th...Marko, you will get the same ObjectContainer in the same thread until you call Db4oUtil.closeObjectContainer(). In a web application if you're using a ServletFilter to close it, then it will be the same ObjectContainer for the life of a single request. <BR/><BR/>Generally, you'll have to re-get your object when submitting, then copy the fields. This is a big pain, I realize, but hopefully db4o will have better ID support soon. Keep an eye on <A HREF="http://tracker.db4o.com/jira/browse/COR-177" REL="nofollow">COR-177</A>. <BR/><BR/>I make good use of <A HREF="http://jakarta.apache.org/commons/beanutils/" REL="nofollow">BeanUtils </A> from Apache for copying object fields.Travis Reederhttp://www.blogger.com/profile/01398330633165910535noreply@blogger.comtag:blogger.com,1999:blog-7774229.post-1159185493267001392006-09-25T04:58:00.000-07:002006-09-25T04:58:00.000-07:002006-09-25T04:58:00.000-07:00Can someone please read this topic: http://develop...Can someone please read this topic: http://developer.db4o.com/forums/thread/29406.aspx on the db4o forum, i'm having too much problems with duplicating objects when storing object that has another object in it. I made my program just like travis reeder said, I should be getting the same objectcontainer over and over, but this seems not to be the case...Marko Domanovichttp://www.blogger.com/profile/04343373204938050772noreply@blogger.comtag:blogger.com,1999:blog-7774229.post-1152204530234213492006-07-06T09:48:00.000-07:002006-07-06T09:48:00.000-07:002006-07-06T09:48:00.000-07:00Although this can be used in any applicaion, it ca...Although this can be used in any applicaion, it can definitely handle multiple connections from multiple tomcat requests with no problem. For each request, you can use Db4oUtil.getObjectContainer() throughout the entire request cycle and you'll be sure to get the exact same ObjectContainer for each call. Be sure to close the connections at the end of each request though - Db4oUtil.closeObjectContainer(). <BR/><BR/>Also, if you think you'll be getting heavy traffic, you may want to plug a Connection Pooling mechanism in there.Travis Reederhttp://www.blogger.com/profile/01398330633165910535noreply@blogger.comtag:blogger.com,1999:blog-7774229.post-1152202783715494512006-07-06T09:19:00.000-07:002006-07-06T09:19:00.000-07:002006-07-06T09:19:00.000-07:00Is the db4oUtil.java class all I need to begin usi...Is the db4oUtil.java class all I need to begin using db4o with Tomcat? Will the helper class be able to handle multiple connections to the db4o server like a typical web applications? I can't believe its could be that easy :)Michaelhttp://www.blogger.com/profile/15951796402478729693noreply@blogger.com