java代寫-The Solar System Model

CS-110 2018/19 – Coursework 2:

The Solar System Model

As before the first part of the marking process is automated – your code will be automatically compiled and run. This time however:

  • The ‘main’ automatic test will use a class that I will supply which will tell you if your code passes or fails. (This wasn’t possible last time because you didn’t know about classes.)
  • You should not write a main method yourself (except possibly – hint! – for your own testing)

    The Solar System Model

    You are going to write a class (or ideally classes 英国作业代写,代写英文,英文论文润色代考价格-论文代写高质量平台– hint!) that models solar systems in a very

    英国作业代写,代写英文,英文论文润色代考价格-论文代写高质量平台minimal way. (And please don’t be one of those picky people who point out “there is only one solar system; others are planetary systems” – doesn’t help).

    Our solar systems will have:

  • A name
  • A luminosity

  • A series of zero or more planets each of which has
    • A name
    • A mass (expressed in terms of Earth-masses – so the mass of the Earth is 1.0)
    • A distance from it’s star (expressed in Astronomical Units, or AU- where the Earth is 1.0 AU from the Sun)
    • An orbital period expressed in years.However, since the orbital period is a function of the distance, you will not specify the orbital period when you create a planet – instead it will be computed (formula is below).

      Also, based on the luminosity of its star, its mass, and its distance from its star, a planet may be


      What You Must Write

      1. A set of classes (for full marks there must be more than one) to define a solar system. You

      must stick to the names (including exact case) and methods below or your code will not work

  • Name of Class – the primary class must be called SolarSystem: you may write sub classes to help you implement it in a better way if you wish (and there can be as many as you like – don’t over do it – and they can be called what you like). There should be at least one ‘sensible’ additional class here (required for full marks) which follows obviously from the structure of the problem (you can have more but, as said, don’t overdo it).
  • Constructor – there should be one constructor SolarSystem(String name, double luminosity) where name is the name you wish to give a solar system, and luminosity is the brightness of the star (on a scale Sun==1.0).
  • addPlanet – there should be a method void addPlanet(String name, double mass, double distance) that creates a new planet with the specified name, mass and distance from its star.
  • toString – there should be a method String toString() that returns a string containing:
    • The name of the solar system followed by a newline;
    • data for each planet in the following exact format with each line ending in a newline.

      Planet X has a mass of A Earths, is BAU from its star, and orbits in C years: could be habitable? D

      where X is the name, A is the mass, B is the distance from the star (both as entered above when a planet is created by a call to addPlanet; C is the orbital period rounded to three decimal places; and D is the word ‘yes’ or ‘no’. In all cases, A, B and C need to be returned rounded to three decimal places. It is up to you if you store them this way, or round them when they are output.

  • Note that as before the exact format of the text string is critical to the correct operation of the program – you can find examples of the format in the test file (included with the coursework) called
  • Other methods – you will need to provide other methods (and maybe constructors) too: these

    will be up to you and depend on how you approach the problem.

    Testing Part

    Testing your submission will be done by running the class that I have supplied to

    you. To do this, simply put all your java files in the same folder as and type:

    英国作业代写,代写英文,英文论文润色代考价格-论文代写高质量平台javac *.java java AutoTest

    The first line compiles all the Java code (yours and AutoTest.java英国作业代写,代写英文,英文论文润色代考价格-论文代写高质量平台) and the second runs the

    AutoTest class. The output should be:

    Solar System: Pass!

    英国作业代写,代写英文,英文论文润色代考价格-论文代写高质量平台Trappist1: Pass!

    Any other output means your code is not correct, and you need to work out what’s wrong. The

    error is likely to be in the exact format of the output – if you open and read you can see exactly what it expecting (also see Essential Information and Resources below).

    Learning from Feedback

    For this coursework 5% of the marks are available for responding to feedback or showing how you

    have improved from the previous coursework.

  • If your mark for coursework 1 was less than 100% then you should write, in a block comment at the top of your code, how you have responded to feedback. That is, what issues in your first coursework – recorded in the marking rubric – you have improved.

  • If your mark for coursework 1 was 100%, then you should write, in a block comment at the top of your code, in what way you feel you have improved your work (obviously you can’t meaningfully respond to actual feedback in this case).

  • In BOTH cases you should also consider and respond to any of the general feedback (supplied as part of the coursework 1 feedback pack on Blackboard).

    Essential Information

    You will find the following information essential.

  • To calculate the orbital period from the distance where the distance is in AU and the orbital period is in years, the formula is

    period = Math.sqrt(distance*distance*distance);

  • A planet is ‘potentially habitable’ if all the following conditions are true
    • Its m a ss 0.6.
    • Its m a ss 7.0.
    • Its dista n ce 0.75 × (lu min osit y).

    • Its dista n ce 2.0 × (lu min osit y).

    • See the formula above for orbital period for how to do square root in Java
  • When you first get output from it is unlikely to be correct and you will have to work out what is different – you can do this manually but it will take time. Better to copy and paste the actual and expected output into two files in an editor and use that to compare them. For Notepad++ you can download a compare plugin; BBEdit (Mac) does it without any extra plugins. Just google Notepad++ compare files (or BBEdit compare files). This will be a lot easier than manually doing it – you have a computer which is good at things like that, so use it. Alternatively, and quicker/easier/more sophisticated, you can use the currently commented out code at the top and near the bottom in that calls a library method to highlight the differences – see last point in Resources below.
  • One of the most fiddly bits of this will be to get the numbers output by your program and to match exactly. Remember, mass, distance and, orbital period needs to be rounded as the last step in the calculation process – you may either store them in rounded form, or round them before you output them.
  • A TRICKY POINT To calculate a planet’s habitability, you’ll need to know it’s mass and distance (which are properties of planets) and the star’s luminosity (which is a property of the solar system). This can be tricky to do ‘nicely’ – there will be an example in lectures and on Blackboard


    In order to help you, there is a zip file accompanying this coursework. This contains:

  • – this is the test program I will use fortesting. You should run this program using the commands shown above.

  • and PreTest_win.bat – these are the scripts you should run to check your program passes both parts of the tests. They will compile your code and run AutoTest. If you run the test script for your operating system and get the result stated above, your program works correctly.

  • and SolarTest_win.bat – these are the scripts I will run to check your program passes the test. They do exactly the same as and PreTest_win.bat except they also automatically unzip your final submission (see below about creating a zip file for submission). If you run the test script for your operating system once you’ve created the zip file you intend to submit you will be able to check both that your code works and you’ve created the zip file correctly.

  • The Apache Project library file common-lang3.jar. This is a Java Archive file which you can, optionally, use to help you find out where your output differs from that expected in your program. There is guidance on Blackboard on how to use this from the command line, Netbeans and Eclipse. Using library files is very common in practice in programming, so it’s worth starting to learn how to do it. In this case, it uses the (static) StringUtils.difference() method to highlight where two strings differ.

    Guidance Notes

    These are nearly the same as the last assignment.

  • The biggest mistake you can make is failing to start the work early enough – you need to not only get the code written and compiling, but also working and matching the output of the automatic tests. You need to give yourself time to deal with any hitches, and see me if you need to. This was a problem for many people in assignment 1.

  • A related mistake you can make with this coursework is not finishing early enough – this is because you need time to create and check the zip file you have to submit.

  • The second biggest mistake you can make is just to start writing code without thinking about what you are doing. Don’t just jump in and start writing – make a plan!

  • Break the program into parts – you can write a successful solution to this coursework using two classes in total, and you need to break the problem into the parts corresponding to those classes..

  • Remember in object oriented programming: classes are ‘kinds of thing’; objects are actual ‘things’; methods are ‘actions’ that ‘things’ can do (or have done to them). Also remember ‘things’ can be hierarchical – in the Bank Account example in the notes the Bank is one ‘kind of thing’; which is made up of accounts which are another ‘kind of thing’. In this case I’ve already told you above what the ‘kinds of thing’ are.

  • Write and test in parts – there is no need to try to do everything in one go: write the program in parts so you can test and check each part on it’s own without worrying about the rest of it.

  • Don’t be afraid to write test code – if you’re going to write your program in parts, you need write some extra test code. Sometimes people shy away from writing this code when they start – thinking the work is ‘wasted’ if it’s not code they are going to submit. But it makes it easier and quicker to solve the problems you face, so it’s not wasted effort – it’s less effort
  • Don’t be afraid to ask for help – it’s my job to help and guide you (not do it for you though) so please ask if you have problems. Also remember that discussion on the forum is fine and encouraged, provided your not asking exactly how to do it (or telling people exactly how to do it).

  • Don’t be tempted by unfair practice – it’s sometimes tempting to submit someone else’s solution (maybe changed a bit…), or get something off the internet, or ask someone else to do it. If you do this you risk serious penalties for breaching academic integrity. Remember we run submissions though software systems that detect these practices.

  • Read the marking criteria – you have access to the marking rubric on Blackboard that tells you what will be assessed, how many marks are for each part, and what you need to do to get a mark in each category. Please pay attention to this.

  • Don’t get carried away – every year I get advanced solutions to coursework that gets a lower mark than some simpler solutions. This is because the advanced solutions focus too much on the ‘advanced’ things and forget the simpler basics (which are in the marking scheme).

    Preparing for Submission

    The submission for this project will be a zip file called (case must be exact) containing:

  • – your implementation of the class (case must be exact).

  • Any other Java classes you implement – if your implementation uses any other classes, you must include them too (the .java files only – I do not need the .class files).
  • Please do not include
  • It’s important that when you create your zip file you don’t accidentally include the folder yourfiles are in. There are videos uploaded to Blackboard showing you how to do this.
  • Do not just submit a zipped Netbeans or Eclipse project – that won’t work.

Before You Submit

英国作业代写,代写英文,英文论文润色代考价格-论文代写高质量平台After you have created your zip file, make a copy somewhere else on your computer and run either or (depending if you are using a Mac or Windows).

This will run the complete test suite and show you if your code is both correctly zipped and works properly.


英国作业代写,代写英文,英文论文润色代考价格-论文代写高质量平台Please note the submission details very carefully.

  • You must submit your work via the coursework link on Blackboard by 17.00 on Tuesday 11th December 2018. Do not email your work to me. Also ignore the submission time on – the one on Blackboard is correct.
  • You must upload a file called containing your Java code. Also do not submit the .class files – just the .java files.
  • Late submissions will receive a mark of zero in accordance with College policy – although you will get feedback. If you have extenuating circumstances which prevents you from submitting on time, you must inform the Student Office near the main entrance as soon as

    possible in order to make a case to remove the submission penalty. If you don’t you will almost certainly not get the penalty lifted. Note that any case for extenuating circumstances almost certainly needs to be supported by evidence if it is going to be successful.

  • I strongly suggest you make sure you are consistently using either sequences of four spaces or tabs for indenting. Do not mix both as this can often look like inconsistent indenting after it’s been through Blackboard. You can use Netbeans, Eclipse, Notepad++ (or whatever other editor you are using) to automatically do this for you.
  • You will receive feedback and a mark for your work on 21st December 2018.
  • On the same date I will release a range of sample solutions and general feedback – after that date I cannot accept any late submissions regardless of the reason.
  • The assessment criteria for your work are defined by the marking rubric on Blackboard.This defines: the categories you will be assessed against; how many marks are available for each category; and what you need to do to get those marks. It’s important you study this carefully before you attempt the coursework – no matter how good your code is, if it does not meet the assessment criteria you will not get a high mark.
  • The individual feedback you will receive will consist of the marking rubric, identifying how well you have done in each category together with additional comments if appropriate.
  • If you have any problems with submission, send me an email with [submission] (that exact text) in the title, with details of your problem and I’ll advise you what to do – but do not include your actual coursework submission unless you are asked to.