Results 1 to 4 of 4
- 12-01-2011, 10:48 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 3
- Rep Power
- 0
need help with a uni assessment. got stuck
The deadline for submitting your solution to the in-course assessment is 12:00 on Friday 2nd of December. (Note that this is a change from the originally announced deadline and is because I will be away on the 1st December - I need to be in Aberdeen to safely switch off the submission system.)
The assessment is to build an application with two classes (Sample and Analyser). Each Sample contains a value in kelvin from a temperature sensor at some location, and the Analyser object contains a set of methods for analysing these samples. The assessment is structured such that each part builds upon the other, and each part correlates to a CAS band above the pass mark. For example, if you complete only part 1, the mark you receive will be a pass, but will have a mark no greater than CAS 11.
You should submit your solution using the BlueJ submission system that you used last week during the practical. Use exactly the same submission.defs file available above. You should save this submission.defs file within the folder containing your BlueJ project.
Rules for the Assessment
During the lecture on Thursday 24th November, I will go through the assessment and answer any questions that you have about it.
You then work on your assessment on your own.
There is no practical exercise during week 10 of the course, but the practical sessions will run as normal. The tutors at the practical sessions can give you limited advice/guidance on your assessment work. I would recommend that you submit a version of your assessment during the practical just to make sure that this works. Note that you can resubmit as many revisions of your assessment that you wish; later versions will overwrite the earlier submission.
You may then continue to submit further versions of your assessment until the deadline, which is 12pm Friday 2nd December. At the deadline, the submission system will be switched off and no further submissions will be permitted.
You must remember that the work you submit must be your own work. You may use any material from the lectures and practicals, or any other material that you find on-line that can help you with the assessment. If you use material from sources other than the lectures and practicals, you must acknowledge them in a comment. You may not share solutions with other members of the class. If you copy without acknowledgment, then this is plagiarism. All cases are reported to the University's Academic Registrar, and if you are found guilty, penalties include the awarding of zero marks for the assessment concerned, the entire course, or ultimately, in serious cases, the award of no degree at all.
Part 1. (CAS 9-11) The basic classes and addSample method
Create a class called Sample that has three fields representing the minute past midnight in the day that the sample was collected (an int expected to be in the range 0-1439), the location that the sample was collected from (a String) and the value of the sample (an int). These fields should be constants; i.e. their values should not change for the lifetime of the object. (We are assuming that the temperature sensors are accurate to within 1 degree.)
Write a constructor for this class.
Create a class called Analyser that uses Sample. The analyser should contain a collection of Sample objects.
Within the Analyser class, write a constructor.
Within the Analyser class, write a method with signature
public void addSample(int time, String location, int value)
This method should create a new Sample object and add it to the collection only if the value of the sample is greater than or equal to 0 (absolute zero!) and the minute in which it was taken is in the range 0-1439 (there are 1440 minutes in a day, and we are assuming that all samples are from a single day).
Part 2. (CAS 12-14) Listing all samples
Include this method in the Analyser class to populate the collection with a number of samples for testing purposes:
/**
* Populate collection
*/
public void populate()
{
addSample(0, "Fraser Noble", 280); // 00:00 7C
addSample(120, "Fraser Noble", 281); // 02:00 8C
addSample(240, "Fraser Noble", 282); // 04:00 9C
addSample(360, "Fraser Noble", 286); // 06:00 13C
addSample(480, "Fraser Noble", 288); // 08:00 15C
addSample(600, "Fraser Noble", 290); // 10:00 17C
addSample(720, "Fraser Noble", 291); // 12:00 18C
addSample(840, "Fraser Noble", 290); // 14:00 17C
addSample(960, "Fraser Noble", 290); // 16:00 17C
addSample(1080, "Fraser Noble", 289); // 18:00 16C
addSample(1200, "Fraser Noble", 288); // 20:00 15C
addSample(1320, "Fraser Noble", 283); // 22:00 10C NO FAULTS
addSample(1600, "Fraser Noble", 288); // SHOULD NOT BE ADDED
addSample(-600, "Meston", 290); // SHOULD NOT BE ADDED
addSample(60, "Meston", 282); // 01:00 9C
addSample(180, "Meston", 282); // 03:00 9C
addSample(300, "Meston", 284); // 05:00 11C
addSample(420, "Meston", 286); // 07:00 13C
addSample(540, "Meston", 291); // 09:00 18C
addSample(660, "Meston", 289); // 11:00 16C
addSample(780, "Meston", 290); // 13:00 17C
addSample(900, "Meston", 200); // 15:00 -73C
addSample(1020, "Meston", 320); // 17:00 47C
addSample(1140, "Meston", 290); // 19:00 17C
addSample(1260, "Meston", 290); // 21:00 17C
addSample(1380, "Meston", 290); // 23:00 17C SENSOR FAULT
addSample(30, "MacRobert", 279); // 00:30 6C
addSample(150, "MacRobert", 280); // 02:30 7C
addSample(270, "MacRobert", 279); // 04:30 6C
addSample(390, "MacRobert", 281); // 06:30 8C
addSample(510, "MacRobert", 285); // 08:30 12C
addSample(630, "MacRobert", 286); // 10:30 13C
addSample(750, "MacRobert", 287); // 12:30 14C
addSample(870, "MacRobert", 288); // 14:30 15C
addSample(990, "MacRobert", 289); // 16:30 16C
addSample(1110, "MacRobert", 287); // 18:30 14C
addSample(1230, "MacRobert", 281); // 20:30 8C
addSample(1350, "MacRobert", 277); // 22:30 5C HEATING FAULT
addSample(1230, "MacRobert", -5); // SHOULD NOT BE ADDED
}
Write a method that prints out all samples in the collection along with the location from which the sample was taken. For example, this method may print out the following:
[Fraser Noble, 00:00] 280
[Fraser Noble, 02:00] 280
[Fraser Noble, 04:00] 280
[Fraser Noble, 06:00] 280
[Fraser Noble, 08:00] 280
...
Hint: remember the % and / operators on ints.
Part 3. (CAS 15-17) Highest temperature and faulty sensors
Write a method that displays the highest temperature recorded.
Write a method that displays the locations that have faulty sensors. A sensor is assumed to be faulty if it reports a temperature below 258 Kelvin or above 303 Kelvin. From the data above, this method should report that the Meston sensor is faulty.
Part 4. (CAS 18-20) Faulty heating
Add a new field in your Analyser class that is a collection of String. This will be used to record the locations of faulty sensors. Then write a new method (similar to that for part 3(b)) that populates this collection with the locations of faulty sensors. (Hint: have a look at java.util.HashSet.)
Write a method that reports on buildings with faulty heating. The heating is faulty if the sensor is working correctly (i.e. it is not faulty) and the temperature reported in the building during working hours falls below 288K more than once. Assume that working hours are between 08:00 and 19:00.
Fully document your code using Javadoc style.
These is in general the assessment. I am stuck in part 2.
- 12-01-2011, 10:50 PM #2
Member
- Join Date
- Dec 2011
- Posts
- 3
- Rep Power
- 0
Re: need help with a uni assessment. got stuck
public class Analyser
{
// instance variables - replace the example below with your own
private ArrayList<Sample> mySamples;
/**
* Constructor for objects of class Analyser
*/
public Analyser()
{
// initialise instance variables
mySamples = new ArrayList<Sample>();
}
/**
* An example of a method - replace this comment with your own
*/
public void addSample(int time, String location, int value)
{
// put your code here
if( value >= 0 && time >= 0 && time <= 1439) {
mySamples.add(new Sample(time, location, value));
}
}
/**
* Populate collection
*/
public void populate()
{
addSample(0, "Fraser Noble", 280); // 00:00 7C
addSample(120, "Fraser Noble", 281); // 02:00 8C
addSample(240, "Fraser Noble", 282); // 04:00 9C
addSample(360, "Fraser Noble", 286); // 06:00 13C
addSample(480, "Fraser Noble", 288); // 08:00 15C
addSample(600, "Fraser Noble", 290); // 10:00 17C
addSample(720, "Fraser Noble", 291); // 12:00 18C
addSample(840, "Fraser Noble", 290); // 14:00 17C
addSample(960, "Fraser Noble", 290); // 16:00 17C
addSample(1080, "Fraser Noble", 289); // 18:00 16C
addSample(1200, "Fraser Noble", 288); // 20:00 15C
addSample(1320, "Fraser Noble", 283); // 22:00 10C NO FAULTS
addSample(1600, "Fraser Noble", 288); // SHOULD NOT BE ADDED
addSample(-600, "Meston", 290); // SHOULD NOT BE ADDED
addSample(60, "Meston", 282); // 01:00 9C
addSample(180, "Meston", 282); // 03:00 9C
addSample(300, "Meston", 284); // 05:00 11C
addSample(420, "Meston", 286); // 07:00 13C
addSample(540, "Meston", 291); // 09:00 18C
addSample(660, "Meston", 289); // 11:00 16C
addSample(780, "Meston", 290); // 13:00 17C
addSample(900, "Meston", 200); // 15:00 -73C
addSample(1020, "Meston", 320); // 17:00 47C
addSample(1140, "Meston", 290); // 19:00 17C
addSample(1260, "Meston", 290); // 21:00 17C
addSample(1380, "Meston", 290); // 23:00 17C SENSOR FAULT
addSample(30, "MacRobert", 279); // 00:30 6C
addSample(150, "MacRobert", 280); // 02:30 7C
addSample(270, "MacRobert", 279); // 04:30 6C
addSample(390, "MacRobert", 281); // 06:30 8C
addSample(510, "MacRobert", 285); // 08:30 12C
addSample(630, "MacRobert", 286); // 10:30 13C
addSample(750, "MacRobert", 287); // 12:30 14C
addSample(870, "MacRobert", 288); // 14:30 15C
addSample(990, "MacRobert", 289); // 16:30 16C
addSample(1110, "MacRobert", 287); // 18:30 14C
addSample(1230, "MacRobert", 281); // 20:30 8C
addSample(1350, "MacRobert", 277); // 22:30 5C HEATING FAULT
addSample(1230, "MacRobert", -5); // SHOULD NOT BE ADDED
}
/**
* print samples
*/
public void samplesCollection()
{
for(int i = 1; i < mySamples.size(); i++){
System.out.println("Sample Collection " + i);
System.out.println(mySamples.get(i));
}
}
}
compliled no syntax error
- 12-01-2011, 10:52 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 3
- Rep Power
- 0
Re: need help with a uni assessment. got stuck
public class Sample
{
// instance variables - replace the example below with your own
private int time;
private String location;
private int value;
private ArrayList<String> sample;
/**
* Constructor for objects of class Sample
*/
public Sample(int time, String location, int value)
{
// initialise instance variables
this.time = time;
this.location = location;
value = (223 - 313) ;// around -50 to 40 celsius
this.sample = new ArrayList<String>(sample);
}
/**
* String to string
*/
public String toString()
{
String s = "[" + location + ",\t" + time + "]\t" + value;
for(String t : sample) {
s+= "\t" + t + "\n";
}
return s;
}
}
compiled no syntax error
when I'm trying to use the void populate on the analyser class an error appears and has something to do with this line
this.sample = new ArrayList<String>(sample);
could somebody help me please
- 12-01-2011, 11:09 PM #4
Similar Threads
-
Stuck, need help please
By Johnny2009 in forum New To JavaReplies: 3Last Post: 11-03-2011, 10:25 PM -
I'm stuck help!!!
By nobody58 in forum Advanced JavaReplies: 2Last Post: 03-18-2010, 02:52 PM -
Stuck in sea
By programmer_007 in forum JDBCReplies: 1Last Post: 09-17-2009, 04:00 AM -
Im on my last lab!!!! And im stuck...:(
By clanboru15 in forum New To JavaReplies: 5Last Post: 03-13-2009, 01:44 AM -
Java - free online assessment test
By Intelrate in forum Java CertificationReplies: 0Last Post: 11-26-2008, 05:18 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks