| | |
help help plzzzzzzzz
![]() |
•
•
Join Date: Mar 2007
Posts: 6
Reputation:
Solved Threads: 0
hi guys
im an IT student an i have a very important assignment to return in 2 days time and im stuck with it i dnt know what to do. the assignment is as follows.
Write a complete class definition in java for the following.your answer must include at least 2 constructors, a finalizer, a display() method, a menu that allows to test all functions of the class and a main().
Class: MobilePhone
Attributes:ownNumber, calledNumber, status(busy/free)
Methods: dial(), call(), redial(), disconnect(), cancel(), receiveCall(), ValidatePhoneNo().
im counting on you guys your solution will serve me as a very good reference.my book on java is coming only next week i hope i get an answer from you soon.......
thanks a lot.....
im an IT student an i have a very important assignment to return in 2 days time and im stuck with it i dnt know what to do. the assignment is as follows.
Write a complete class definition in java for the following.your answer must include at least 2 constructors, a finalizer, a display() method, a menu that allows to test all functions of the class and a main().
Class: MobilePhone
Attributes:ownNumber, calledNumber, status(busy/free)
Methods: dial(), call(), redial(), disconnect(), cancel(), receiveCall(), ValidatePhoneNo().
im counting on you guys your solution will serve me as a very good reference.my book on java is coming only next week i hope i get an answer from you soon.......
thanks a lot.....
I certainly hope you don't expect us to write the code for you. Not only is it dishonest (we call it "cheating" around here), but there's no point. It's highly doubtful that you'll learn much if anything from it (don't argue, we've heard it before). Maybe you should have paid better attention in class, asked your professor for help, and gotten a book sooner.
On the other hand, if you were to post some incorrect or slightly incomplete code with a description of what's wrong, I'm sure a lot of members would be much more willing to help you get over a couple problems...
On the other hand, if you were to post some incorrect or slightly incomplete code with a description of what's wrong, I'm sure a lot of members would be much more willing to help you get over a couple problems...
•
•
Join Date: Mar 2007
Posts: 6
Reputation:
Solved Threads: 0
hi guys
im an IT student an i have a very important assignment to return in 2 days time and im stuck with it i dnt know what to do. the assignment is as follows.
Write a complete class definition in java for the following.your answer must include at least 2 constructors, a finalizer, a display() method, a menu that allows to test all functions of the class and a main().
Class: MobilePhone
Attributes:ownNumber, calledNumber, status(busy/free)
Methods: dial(), call(), redial(), disconnect(), cancel(), receiveCall(), ValidatePhoneNo().
im counting on you guys your solution will serve me as a very good reference.my book on java is coming only next week i hope i get an answer from you soon.......
thanks a lot.....
im sending you the whole program which i have written but there are lots of missing codes in it plz help me out. example for the method call() what code to write to show the process of calling?
here is the program
import java.io.*;
public class MobilePhone
{
private int ownNumber;
private int calledNumber;
private boolean status; // either busy or free
public MobilePhone()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(" Phone details")
System.out.print(" input your own phone number:");
int ownNumber = Integer.parseInt(r.readLine());
System.out.print("Input the number to call:");
int calledNumber = Integer.parseInt(r.readLine());
Boolean status = free;
}
Public void setData()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(" Phone details")
System.out.print(" input your own phone number:");
int ownNumber = Integer.parseInt(r.readLine());
System.out.print("Input the number to call:");
int calledNumber = Integer.parseInt(r.readLine());
Boolean status = free;
}
public MobilePhone (int ownNumber, ine calledNumber) throws IOException
{
This.ownNumber = ownNumber;
This.calledNumber = calledNumber;
Boolean status = free;
}
Public void dial()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(“Input a number to dial:”);
// there are some codes which need to be added as a user can just dial a number and dnt do anything else or to make a call,disconnect or cancel also.
}
Public void call(0throws IOException
{
Dial();
If(status==busy)
System.out.println(“number busy”);
// some code needed here
Else
System.out.println(“Connecting to number..”);
System.out.println(“call1..”);
Status = busy;
}
Public void redial()throws IOException
{
Call();
// code needed
If(status = = free)
System.out.println(“please wait….”);
System.out.println(“redialing..”);
}
Public void disconnect()throws IOException
{
Call();
Redial();
System.out.println(“Disconnecting…”);
}
Public void receive()throws IOException
{
If (status = = free)
// I really dnt know how to explain it in codes
}
Public void ValidatePhoneNo()throws IOException
{
If (calledNumber = = String)
System.out.println(“Invalid number..”);
// above code is for checking if number input is in characters then error message.
Int len = calledNumber.length
If (len>7 || len<7)
System.out.println(“Invalid phone number..”);
// the part above is to check if it has 7 digits only. I know its not good plz help me out im lost completely.
}
Note:Its been barely 2 months since im learning this language usually I do well in class but this assignment is a little tough because there is no calculations in it and I dnt know how to code these actions.
I wanted to add another method to calculate call duration when a call is being made but I dnt know how to implement it. Ive done some search I know we have to use timemillis to calsulate in milliseconds but im stuck for now. please correct my mistakes and add the codes necessary that are missing.
I will write my main and menu later after I have receive your solution which I must study to be able to continue.please sir help me out.
im an IT student an i have a very important assignment to return in 2 days time and im stuck with it i dnt know what to do. the assignment is as follows.
Write a complete class definition in java for the following.your answer must include at least 2 constructors, a finalizer, a display() method, a menu that allows to test all functions of the class and a main().
Class: MobilePhone
Attributes:ownNumber, calledNumber, status(busy/free)
Methods: dial(), call(), redial(), disconnect(), cancel(), receiveCall(), ValidatePhoneNo().
im counting on you guys your solution will serve me as a very good reference.my book on java is coming only next week i hope i get an answer from you soon.......
thanks a lot.....
im sending you the whole program which i have written but there are lots of missing codes in it plz help me out. example for the method call() what code to write to show the process of calling?
here is the program
import java.io.*;
public class MobilePhone
{
private int ownNumber;
private int calledNumber;
private boolean status; // either busy or free
public MobilePhone()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(" Phone details")
System.out.print(" input your own phone number:");
int ownNumber = Integer.parseInt(r.readLine());
System.out.print("Input the number to call:");
int calledNumber = Integer.parseInt(r.readLine());
Boolean status = free;
}
Public void setData()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(" Phone details")
System.out.print(" input your own phone number:");
int ownNumber = Integer.parseInt(r.readLine());
System.out.print("Input the number to call:");
int calledNumber = Integer.parseInt(r.readLine());
Boolean status = free;
}
public MobilePhone (int ownNumber, ine calledNumber) throws IOException
{
This.ownNumber = ownNumber;
This.calledNumber = calledNumber;
Boolean status = free;
}
Public void dial()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(“Input a number to dial:”);
// there are some codes which need to be added as a user can just dial a number and dnt do anything else or to make a call,disconnect or cancel also.
}
Public void call(0throws IOException
{
Dial();
If(status==busy)
System.out.println(“number busy”);
// some code needed here
Else
System.out.println(“Connecting to number..”);
System.out.println(“call1..”);
Status = busy;
}
Public void redial()throws IOException
{
Call();
// code needed
If(status = = free)
System.out.println(“please wait….”);
System.out.println(“redialing..”);
}
Public void disconnect()throws IOException
{
Call();
Redial();
System.out.println(“Disconnecting…”);
}
Public void receive()throws IOException
{
If (status = = free)
// I really dnt know how to explain it in codes
}
Public void ValidatePhoneNo()throws IOException
{
If (calledNumber = = String)
System.out.println(“Invalid number..”);
// above code is for checking if number input is in characters then error message.
Int len = calledNumber.length
If (len>7 || len<7)
System.out.println(“Invalid phone number..”);
// the part above is to check if it has 7 digits only. I know its not good plz help me out im lost completely.
}
Note:Its been barely 2 months since im learning this language usually I do well in class but this assignment is a little tough because there is no calculations in it and I dnt know how to code these actions.
I wanted to add another method to calculate call duration when a call is being made but I dnt know how to implement it. Ive done some search I know we have to use timemillis to calsulate in milliseconds but im stuck for now. please correct my mistakes and add the codes necessary that are missing.
I will write my main and menu later after I have receive your solution which I must study to be able to continue.please sir help me out.
Number one recommendation: run your code through a compiler. There's a few really simple bugs in it. Like missing semicolons, inconsistent capitalization, and using
You're missing a semicolon after the first System.out.println, and you're trying to declare status locally (and Boolean shouldn't be capitalized, but in this case it should just be removed). If you're using Java 1.5 or later, check out the java.util.Scanner class. It makes input from the console a lot easier, where you can do things like this:
setData is exactly the same as the empty constructor. You could just have the constructor call setData to avoid duplicated code.
Why do you set the number to call in setData when you're just going to prompt for it in dial? Choose one (probably dial). And then dial needs to try connecting and set the status accordingly. That's logic you'll have to figure out.
In call, when you have
For call, you might want to have it take a phone number as a parameter so you know what number you're calling. That way you can save the last dialed number for when you implement redial (and redial would mainly be
Receive needs to check if the current line is busy or not. If it is, then you have to tell the caller that somehow (I'd use a boolean again here, and return false). Otherwise, you should set it to busy and tell the caller that the call has been accepted (e.g. return true). You might want to somehow record the number of the caller as well (probably as a parameter) but I think this isn't required for your assignment.
In ValidatePhoneNo, you don't need to check if calledNumber is a String. Since you declared it as an int, it'll be an int. and checking the phone length can be done as
= = instead of ==. Anyways, moving on... Java Syntax (Toggle Plain Text)
public MobilePhone() throws IOException { BufferedReader r = new BufferedReader(InputStreamReader(System.in)); System.out.println(" Phone details") System.out.print(" input your own phone number:"); int ownNumber = Integer.parseInt(r.readLine()); System.out.print("Input the number to call:"); int calledNumber = Integer.parseInt(r.readLine()); Boolean status = free; }
Java Syntax (Toggle Plain Text)
Scanner consoleInput = new Scanner(System.in); int anInt = consoleInput.nextInt(); String aWord = consoleInput.next(); String aLine = consoleInput.nextLine();
Why do you set the number to call in setData when you're just going to prompt for it in dial? Choose one (probably dial). And then dial needs to try connecting and set the status accordingly. That's logic you'll have to figure out.
In call, when you have
if(status == busy), are you checking if the current phone or the dialed one is busy? Depending on your requirements, there might be a need for both. If the current phone is busy, you shouldn't even call dial. To check if the other line is busy, you could have dial return a boolean.For call, you might want to have it take a phone number as a parameter so you know what number you're calling. That way you can save the last dialed number for when you implement redial (and redial would mainly be
call(lastNumberDialed)).Receive needs to check if the current line is busy or not. If it is, then you have to tell the caller that somehow (I'd use a boolean again here, and return false). Otherwise, you should set it to busy and tell the caller that the call has been accepted (e.g. return true). You might want to somehow record the number of the caller as well (probably as a parameter) but I think this isn't required for your assignment.
In ValidatePhoneNo, you don't need to check if calledNumber is a String. Since you declared it as an int, it'll be an int. and checking the phone length can be done as
if(len != 7) rather than using > || <. If you just want to make sure that it's a 7-digit number, you can just check if String.valueOf(calledNumber).length == 7 rather than the syntactically wrong thing you were doing. And the function should probably return whether the number is valid rather than just printing out the result. •
•
Join Date: Mar 2007
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
I certainly hope you don't expect us to write the code for you. Not only is it dishonest (we call it "cheating" around here), but there's no point. It's highly doubtful that you'll learn much if anything from it (don't argue, we've heard it before). Maybe you should have paid better attention in class, asked your professor for help, and gotten a book sooner.
On the other hand, if you were to post some incorrect or slightly incomplete code with a description of what's wrong, I'm sure a lot of members would be much more willing to help you get over a couple problems...
im sending you the whole program which i have written but there are lots of missing codes in it plz help me out. example for the method call() what code to write to show the process of calling?
here is the program
import java.io.*;
public class MobilePhone
{
private int ownNumber;
private int calledNumber;
private boolean status; // either busy or free
public MobilePhone()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(" Phone details")
System.out.print(" input your own phone number:");
int ownNumber = Integer.parseInt(r.readLine());
System.out.print("Input the number to call:");
int calledNumber = Integer.parseInt(r.readLine());
Boolean status = free;
}
Public void setData()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(" Phone details")
System.out.print(" input your own phone number:");
int ownNumber = Integer.parseInt(r.readLine());
System.out.print("Input the number to call:");
int calledNumber = Integer.parseInt(r.readLine());
Boolean status = free;
}
public MobilePhone (int ownNumber, ine calledNumber) throws IOException
{
This.ownNumber = ownNumber;
This.calledNumber = calledNumber;
Boolean status = free;
}
Public void dial()throws IOException
{
BufferedReader r = new BufferedReader(InputStreamReader(System.in));
System.out.println(“Input a number to dial:”);
// there are some codes which need to be added as a user can just dial a number and dnt do anything else or to make a call,disconnect or cancel also.
}
Public void call(0throws IOException
{
Dial();
If(status==busy)
System.out.println(“number busy”);
// some code needed here
Else
System.out.println(“Connecting to number..”);
System.out.println(“call1..”);
Status = busy;
}
Public void redial()throws IOException
{
Call();
// code needed
If(status = = free)
System.out.println(“please wait….”);
System.out.println(“redialing..”);
}
Public void disconnect()throws IOException
{
Call();
Redial();
System.out.println(“Disconnecting…”);
}
Public void receive()throws IOException
{
If (status = = free)
// I really dnt know how to explain it in codes
}
Public void ValidatePhoneNo()throws IOException
{
If (calledNumber = = String)
System.out.println(“Invalid number..”);
// above code is for checking if number input is in characters then error message.
Int len = calledNumber.length
If (len>7 || len<7)
System.out.println(“Invalid phone number..”);
// the part above is to check if it has 7 digits only. I know its not good plz help me out im lost completely.
}
Note:Its been barely 2 months since im learning this language usually I do well in class but this assignment is a little tough because there is no calculations in it and I dnt know how to code these actions.
I wanted to add another method to calculate call duration when a call is being made but I dnt know how to implement it. Ive done some search I know we have to use timemillis to calsulate in milliseconds but im stuck for now. please correct my mistakes and add the codes necessary that are missing.
I will write my main and menu later after I have receive your solution which I must study to be able to continue.please sir help me out.
Ok, I'll put this bluntly: I'm not going to post any code here. You need to figure it out on your own. I gave you a list of things you need to do as well as several suggestions for how to continue after that. I will not do your work for you. I don't have time to do your work. You can't afford to pay me to do your work. You'll need to do your work. Did you even read my second post?
Last edited by Infarction; Apr 1st, 2007 at 5:18 am.
![]() |
Similar Threads
- plzz solve my problem (C++)
- Need guidance. (Python)
- Need help with an assignment that is due tomorrow plzzzz (C++)
- help....... (VB.NET)
- major priojects (VB.NET)
- help with file header (C#)
- code for ......anyone??? (C)
- hi need help (C)
Other Threads in the Java Forum
- Previous Thread: Conversion code-What is wrong? Help me pls
- Next Thread: FTP scripting help
| Thread Tools | Search this Thread |
account android api applet application array arrays automation awt bidirectional binary birt bluetooth busy_handler(null) chat class classes client code columns component database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source plazmic print problem program programming project property recursion ria scanner search server set smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree webservices windows






