Is coding ok for coursework?

So i have a class with the specifications as so
The Aircraft
This must be an object which contains the passengers.  You must use a Java Collection object (not an array) to hold the Passengers and this must limit the number of passengers either when the maximum seat number is reached (250 for this demo) or if the maximum weight is reached (21300). The aircraft should calculate the fare for each passenger as they are added and keep track of the revenue being generated (total fares of all the passengers).  There are also other things like the aircraft seat number is dependant on the aircraft wait, and there is a rule for the price the Person pays depending on their total weight. This is what i have done
import java.util.*;
public class Aircraft
     private List<Passenger> passengers = new ArrayList<Passenger>();
          public Aircraft(Passenger element)
               this.addPassenger(element);
          public void addPassenger(Passenger element)
               try
                    if (passengers.size()<numberOfSeats() && aircraftWeight()<21300.00)
                         passengers.add(element);
               catch(Exception e)
                    System.out.println(e);
                    System.out.println("Passenger number reached or Passenger total weight reached");
          public double passengerTotalWeight()
               double weight = 0.0;
                    for(Passenger a: passengers)
                         weight = a.getWeight() + a.getLuggage().getWeight();
               return weight;
          public double aircraftWeight()
               double weight = 0.0;
                    for(Passenger a: passengers)
                         weight += passengerTotalWeight();
               return weight;
          public double passengerFair()
               double fair = 400.0;
               double weight = passengerTotalWeight();
                    for(Passenger a: passengers)
                         if(weight >= 50 && weight < 100)
                              fair = 400 + ((weight - 50) * 5);
                         else if(weight >= 100 && weight < 150)
                              fair = 650 + ((weight - 100) * 10);
                         else if(weight > 150)
                              fair = 1150;
               return fair;
          public int numberOfSeats()
               int seats = 250;
               double weight = passengerTotalWeight();
                    if(weight>100)
                         seats = 213;
                    else if(weight>150)
                         seats = 142;
               return seats;
}I just basically wanted to know if the programming and style is ok. I am just a bit unsure whether sections like this
if (passengers.size()<numberOfSeats() && aircraftWeight()<21300.00)Where i am doing it with methods is ok. I am basically looking for the best way to do this class as a professional programmer would. Any advise would be great
cheers

Looking at it, i would say that it is adding 0.0 each time or its going to produce too high a value due to it not being assigned the weight of just one Passenger each time, but the total weight. I havnt got a tester going yet, but i think its really about time i work on that so i can do some println's.
I just thought of somthing else, so i changed my code slightly. The passengerTotalWeight method returns the total weight (their weight plus luggage weight) for a single Passenger (not for all passengers). Its the aircraftWeight method which returns the passengerTotalWeight for all passengers. So for the aircraftWeight method, i didnt think an extended for loop was needed. I also added a new variable. This is how it looks at the moment
public double passengerTotalWeight()
               double weight = 0.0;
                    for(Passenger a: passengers)
                         weight = a.getWeight() + a.getLuggage().getWeight();
               return weight;
          public double aircraftWeight()
               double weight = 0.0;
               double totalWeight = 0.0;
                    for(int x=0; x<=passengers.size(); x++)
                         double newWeight = passengerTotalWeight();
                         totalWeight = weight + newWeight;
               return totalWeight;
          }   Not too sure if i am getting closer. I will start working on a tester.

Similar Messages

  • Standard (ABAP coding) delivery for SES in CRM 2007?

    Hello,
    I found the Netweaver functionality "Search Engine Service (SES)" on help.sap.com.
    This function sounds great. Documents on SDN (like "https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/21404ae5-0601-0010-0395-a6d917099f1a" and "https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a751a1ec-0a01-0010-f0ba-89e4c5cd0261") tell that this functionality is part of Netweaver ABAP and that there're already ready-to-use implementations for business objects in SAP ERP.
    However, we're using CRM and want to extend the search functionalities using SES. I was able to create an index for business object BUS1006 (business partner) and insert some data, search for it, and so on. However, it was necessary to do all the data selection manually.
    I found enhancement spot COM_PRODUCT_SE which seems to deal with the product search using SES. I tried with business object BUS1006 where enhancement spot HRHAP00_SES seems to be used - however with no (sample) implementation. When creating/updating an index using report COM_SE_DISPATCHER, the methods of the corresponding BADI implementation are called to retrieve object IDs, attribute names, attribute values and so on. As described before, this seems to be not delivered by SAP standard, thus, we have to do the coding in methods IF_HAP_SES_BUSOBJ_AESGET_ATTRIBUTE_NAME_LIST, IF_HAP_SES_BUSOBJ_AESGET_ATTRIBUTE_VALUES, IF_HAP_SES_BUSOBJ_AES~GET_OBJECT_ID_LIST on ourselves?
    So my question is: Is the ready-to-use implementation of SES for CRM business objects already contained (and I didn't find it) or will it be part of further shipments?
    Many thanks & regards
    Wolfgang

    Hi Wolfgang,
    unfortunately, CRM did not include the SES methods in all their objects.
    CRM will focus on enabling their objects on "Embedded Search", which is basically "the next version of SES" that will beavailable for Business Suite 2008 applications. This will then also enable CRM content to be searched through SAP NetWeaver Enterprise Search.
    Of course you can - in the meantime - attempt your own implementation of SES for CRM objects. Unfortunately, I am not the right guy to further help with coding details for that.
    Best, Karsten

  • Could not find coding page for receiving system

    Hi,
    We have set up the configuration of RFC connections in SM59. We want to send an IDoc from a Unicode to a non-Unicode system. Message 'Could not find coding page for receiving system' appears. We activated some solutions described in OSS notes and added the required authorization to the communication user but it still doesn't work. What else can cause (solve) this problem?
    Regards, Jan

    Hello Jan,
    I had the following situation:
    After seup of an ALE/IDOC scenario with another SAP but Non unicode system sometimes the outbound PROJECT idocs failed with the error message "Could not find code page for receiving system". Status of Idoc was 02. When reprocessed some minutes later with report RBDAGAIN it worked.
    It turned out that for what'o'ever reason the connectivity was down for a very short time but long enough to get the Idocs failed.
    That's what I meant with the error text could be misleading.
    We solved this problem with a daily job with report RBDAGAIN for reprocessing.
    Regards
    Michael

  • I need the coding example for encapsulation

    hi all
    i need the coding example for encapsulation
    thanks in advance

    hi all
    i need the coding example for encapsulation
    thanks in advanceI see a man, hes trapped on the other side.. what Sam?... yes ... hes wearing a hood, he's a hooded gentleman, perhaps a monk who practised the black arts.... he says... "google for the answer"...

  • Dedicated coding mask for standard template.

    Hi Experts
    I wish to maintain coding mask for: various varities of projects like:
    1) PP/00000-00-00-00
    2) PS/00000-00-00-00
    3) PA/00000-00-00-00
    To have the template functionality also in place, please suggest which of the following is best?
    1) The above coding masks are allowed for both operative and standard. It means, the number series contains mix of both std and operative projects.
    2) To have a dedicated coding mask ST/00000-00-00-00 which will be a common standard template for creating Operative projects using the above masks. I am still having doubt since i could not test this as the existing system coding masks not allowed for modication.
    I request the experts, to suggest a best practice in this regard.
    warm regards
    ramSiva

    The number series will not contain the mix of both operative and standard structures as you have mentioned in point 1. Please check.
    As for point 2, Kabir is right. Create a new mask for standard structures and lock it for operative projects.
    Regards,
    Ajinkya
    Edited by: Ajinkya Vaidya on Oct 30, 2009 6:08 AM

  • Coding conventions for SERVLETS

    Where to find coding conventions for Java Servlets ?

    Why would they be any different from the coding conventions for all of Java?
    http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

  • Difficult with different coding masks for operative and std templates.

    Hi Experts
    I have below coding masks
    OP-XXXX-XX-XX For operative structures (not allowed for std templates)
    ST-XXXX-XX-XX For std tempplates (not allowed for operative structures)
    But i am unable to create operative project using std template.
    I have disabled Lck for std mask and tried, then i could create project but the operative project got created with WBS element's short id 'ST' and not with 'OP'
    How to ensure getting the right WBS id while copying from different standard coding mask?
    warm regards
    ramSiva

    Hi Ahmed
    I have gone through help, but i did not get any clue to make use different project IDs for std and operative.
    I am just looking for this to have dedicated structures for both std and operative, due to which one can easily recognise the nature by seeing the project id.
    Of course, it is very comfortable using unique project ID / coding mask for both. Still i am exploring. You may suggest if feasible.
    warm regards
    ramSiva

  • Need coding support for Accessing MYSQL stored procedure from java

    Hi every one,
    I need coding support for accessing Mysql stored procedure from java and JSP.
    Please help me
    pranav

    You'd better have a recent version of MySQL, because earlier ones didn't support stored procs.
    If your MySQL and driver support stored procs, maybe you just need a JDBC stored proc tutorial.
    %

  • [svn] 2093: fix air-config. xml so that there are no hard-coded values for the build number.

    Revision: 2093
    Author: [email protected]
    Date: 2008-06-16 12:57:18 -0700 (Mon, 16 Jun 2008)
    Log Message:
    fix air-config.xml so that there are no hard-coded values for the build number. This gets updated from the root build.xml by using a combination of a value from build.properties, release.version, and a value passed into build.xml build.number.
    partial fix for sdk-15812
    Ticket Links:
    http://bugs.adobe.com/jira/browse/sdk-15812
    Modified Paths:
    flex/sdk/branches/3.0.x/frameworks/air-config.xml

    I need to add just one more thing and that is on battery life.  Last night I sat with the rMBP on my lap installing software, surfing the web, answering emails for close to 4 and 1/2 hours.  At the point I took it back to the charger it still was showing a computed battery time remaining of 3.5 hours.
    Today I had two VMs open and took the machine of the charger and sat outside with my dogs for about 30 minutes.  During this time I was working in both VMs, editing and compiling code.  My battery life estimate showed a good solid 4 hours. 
    This is roughly 6 times greater than what I had with my 2010 MBP and it too had a SSD.  I am not sure why but this retina MBP just seems to not work as hard doing anything that caused my 2010 MBP to struggle.
    While the battery life is certainly better than I expected it is clear that load can change that very rapidly. So I think I still need to visit clients with an external battery or charger in hand.  But I don't think I will be quite so scared that my laptop will simply run out of power before I can even get it plugged in.

  • IPhoto suddenly crashing after it's open for 3 seconds.Its saying Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ __NSCFDictionary 0x18d70d10 valueForUndefinedKey:]: this class is not key value coding-compliant for the key

    Iphoto is suddenly crashing after about 3 seconds on my MacBook Pro. - Here is problem report
    Crashed Thread: 46  Import thread 0
    Exception Type: EXC_BREAKPOINT (SIGTRAP)
    Exception Codes: 0x0000000000000002, 0x0000000000000000
    Application Specific Information:
    *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFDictionary 0x18d70d10> valueForUndefinedKey:]: this class is not key value coding-compliant for the key .'
    Why? all of a sudden??
    Thanks

    Wow, that' s awesome, I encountered the same problem with ya today when trying implement Pickers in Tabbar, and can't figure out why, the debugger just throw back such vague message and guess what ? I spent like 3 hours banging my head against the wall wonder why it's not working, I using XCode 2.2.1, my debugger wont work ( program won't stop at break points for what ever I tried ), and not very friendly with those newbie like me - really don't know where are all the Apple's software developer 1337 ? As I remembered, all the good ones goes for the hardware, "the rest" goes for the software =)), but thanks again, thanks, and again, click the tab bar, set both the class and nib file would get rid of the errors, if it would help some one, the credit goes to the two above, say thanks to them, like me. Have a nice day guys, I 'ma happy .

  • Corrected coding please for repeating image

    I have searched the internet/the tutortials and cannot get the correct coding for a repeat image vertically in a table on the left hand side of the webpage.  I believe the coding should be repeat-y but I tried all the examples and could not get it to work.  I finally found a way to get it on but I know there is better coding.  This is what I have so far:
    <tr><th width="526" height="865" valign="top" scope="row"><table width="121" height="864" border="0" align="left" cellpadding="0" cellspacing="0">
            <tr>
              <th width="121" height="864" valign="top" scope="row"><p><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" />
              <img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" />
              <img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /><img src="../Images/border.jpg" width="80" height="80" /></p></th>
            </tr>
          </table>

    I do not want a complete page covered with this design, merely the left-hand border side.
    as mentioned background-repeat:repeat-y; will do just that.
    Some of us, especially in this economic times, cannot afford to spend thousands to have a website created, so we do the best we can.  While I agree tables are difficult for they were indeed designed to place data, and I have eliminated tables where ever I could, this was the only way I could get the result needed.
    agreed times are tough, but seriously working in tables adds more time, more headaches and therefore costs more money.
    Sorry to have bothered you.  Shame Dreamweaver was bought out by Adobe but then, there are other programs; perhaps there forums will have more tolerance for one of us old duffers.
    whats with being all touchy? you asked for "correct coding please for repeating image?"
    and thats what I gave you.
    apart from that I mentioned not to use tables. which is a good thing to take on board.
    for example
    1. Tables are usually more bytes of markup. (Longer to download, and more bytes of traffic for the host.)
    2. Tables usually prevent incremental rendering. (Takes longer for the user to see anything on the page.)
    3. Tables may require you to chop single, logical images into multiple ones. (This makes redesigns total hell, and also increases page load time [more http requests and more total bytes].)
    4. Tables break text copying on some browsers. (That's annoying to the user.)
    5. Tables prevent certain layouts from working within them (like height:100% for child elements of <td>). (They limit what you can actually do in terms of layout.)
    6. Once you know CSS, table-based layouts usually take more time to implement. (A little effort up-front learning CSS pays off heavily in the end.)
    7. Tables are semantically incorrect markup for layout. (They describe the presentation, not the content.)
    8. Tables make life hell for those using screen readers. (Not only do you get the other benefits of CSS, you're also helping out the blind/partially-sighted. This is a Good Thing.)
    9. Tables lock you into the current design and make redesigns MUCH harder than semantic HTML+CSS. (Have you seen CSS Zen Garden?)
    (source - http://phrogz.net/css/WhyTablesAreBadForLayout.html)

  • Where is coding guideline for SharePoint 2013 available?

    Can any one suggest where is coding guidelines and best practices for SP 2013 development is available?

    Hi,
    According to your post, my understanding is that you want to know the best practices for SharePoint 2013 development.
    There are some articles cover best practices targeted towards software developers in SharePoint 2013, you can refer to them.
    http://social.technet.microsoft.com/wiki/contents/articles/13373.sharepoint-2013-what-to-do-farm-solution-vs-sandbox-vs-app.aspx ,
         discusses when to use farm solutions, sandbox solutions, or sharepoint      apps.
    http://social.technet.microsoft.com/wiki/contents/articles/13637.sharepoint-2013-best-practices-what-client-api-should-you-choose-when-building-apps.aspx ,
         guidelines to help you pick the correct client API to use with your app.
    http://msdn.microsoft.com/en-us/library/jj164060(v=office.15).aspx       
    http://social.technet.microsoft.com/wiki/contents/articles/16343.sharepoint-2013-best-practices-setting-up-a-dev-environment-for-windows-apps-and-sharepoint.aspx ,
         describes how to set up a dev environment needed for creating Windows Apps      that leverage SharePoint.
    http://social.technet.microsoft.com/wiki/contents/articles/16353.sharepoint-2013-best-practices-working-with-connection-strings-in-auto-hosted-sharepoint-apps.aspx ,
         discusses how to deal with connection strings in auto-hosted apps.
    For more reference:
    http://social.technet.microsoft.com/wiki/contents/articles/12438.community-best-practices-for-sharepoint-2013.aspx
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • What are the best coding standards for ADF 11g?

    Hi,
    Do we have any link that will suggest the best coding standard practices used for ADF 11g?
    I am looking out from the perspective of some standards that can be defined before starting my project to know the team on how to
    1. Minimize Duplicity and max reusability of code
    2. Package the code
    3. Resource bundle usage and its calls
    4. Maintainning format consistency eg. date display format, number format
    5. Exception handling
    6. Logging
    7. Namiing conventions
    Also then we might have standards on
    1. Task flow dev.
    2. EO and VO creation standards
    3. UI development standards [purely ADF component based]
    Thanks in advance
    Edited by: user8925296 on May 26, 2010 3:24 PM

    The ADF Enterprise Methodology Group has a page on standards that gives you a starting point on many of your questions: http://groups.google.com/group/adf-methodology/web/adf-coding-standards
    John

  • Coding PCR for Payroll

    Hi Experts,
    Can you please help me in coding this PCR :
    1) Compare the amt in two wagetypes 2000 and 3000.
    a) If wagetype 2000 does not exist in Input Table, then simply pass WT 3000 to the Output Table
    b) If wagetype 3000 does not exist in Input Table , then simply pass WT 2000 to the Output Table
    c) If both the wagetypes exist in Input Table, pass the WT which has lesser amt to the Output Table.
    Regards,
    Somdeb.

    Hi Shyam,
    Thank you for the inputs.
    The requirement has changed a bit:
    I am running into this problem:
    2000
    ADDWT *
    AMT?&/194  (Put the amt value of /194 to amt in WT2000)
    <
    =
       NUM=4
       ADDWT 3000 (Dispaly WT 2000 as WT 3000 in th Output Table)
    >
    ====================================================
    Though the amt in  /194 = amt in WT 2000 = 37.01
    System is taking WT 2000 to be more than that of /194
    Can you please help.

  • Coding standards for Web dynpro ABAP

    Hello all,
    Can anybody please help me by providing the code review checklist for Web dynpro ABAP?
    Thanks and Regards,
    Rohini Shankar

    Hello friend,
    WebDynpro     *
    1     Do not implement Data intensive operations in UI layer     
    2     Avoid database selects in the WebDynpro code.Use the corresponding BAPIs ,Methods     
    3     Are ABAP OO Classes like Assistance class are being used for application coding ?     
    4     Are Windows/Views only used for the sole purpose of hosting views and context?     
    5     Are a reasonable number of views put in a single WD Component instead of creating multiple WD Components ?     
    6     Unneccessary usage of dynamic programming and dynamic component avoided      
    7     Are singleton nodes used in case of nesting in the context ?     
    8     Is deep nesting of containers, Groups and Tabstrips avoided ?     
    9     Is the UI element TreeByKey or TreeByTableNestingColumn used instead of the Tree UI element ?     
    10     Is the checkbox "Accessibility Checks Active" ticked in the WD Component properties     
    11     Are the WD Component Instances deleted when no longer needed (IF_WD_COMPONENT_USAGE=>DELETE_COMPONENT)     
    12     Are the OTR texts defined  for all the labels, texts(where ever appropriate) in properties of all the UI elements      
    13     Has the Generation limit been checked for all the components developed     
    14     Sufficients commets are written at the beginning of every major block to explain the processing logic.     
    *Error Handling     *
    1     Is SY-SUBRC checked after CALL function modules      
    2     Use Assertions if you face unexpected errors which usually never ever occur!     
    Extended Check and Clean Up
    1     Have following been removed :     
         ·      Unused variables                       
         ·      Unused text elements                   
         ·      Unused tables from TABLES statement     
         ·      Commented out parts of the code     
         ·      Code segments which do nothing     
    2     Is extended program check completed  and all errors/warnings removed      
    These are the things which i used for my project.
    Thanks,
    Sri Hari

Maybe you are looking for