This discussion is now closed.
/**
public class Mobile {
private String imac;
private GreenFang connection;
private boolean paired;
/**
*Create a Mobile of the type passed in as a String
*/
public Mobile(String type){
this.imac = imac;
paired = false;
}
/**
* Pass in the device that you wish connect to. The device must implement
*the GreenFang interface
*/
public void connect (GreenFang greenFangConnection){
if(greenFangConnection != null ){
connection = greenFangConnection;
paired = true;
}
}
/**
*Disconnect an existing connection. Only successful if already connected
*to the GreenFang passed in
*/
public void disconnect(GreenFang greenFangConnection){
if (connection == greenFangConnection){
connection = null;
paired = false;
}
else{
System.out.println("Can't disconnect - not connected in the first place");
}
}
/**
*Call this method when connected to a GreenFang device to pass your message
*/
public void sendGreenFangMessage(String message){
if (paired){
connection.receiveMessage("Message from "+imac+":"+message);
}
else{
System.out.println("No GreenFang connection present");
}
}
}
/**
*Devices implementing this interface can communicate
*/
public interface GreenFang{
/**
*receives a message as String
*/
public void receiveMessage(String information);
}
public abstract class MobileTest implements GreenFang {
public static void main(String[] args) {
Mobile receiveMessage1 = new Mobile();
String answer = receiveMessage1.sendGreenFangMessage();
System.out.println(answer);
}
}
Last reply 1 day ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 2 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]Last reply 1 day ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 2 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]