No idea where to start on this. We were given a weird class that generates rendom phone numbers, but apart from that, nothing.GRADE 10 CELL PHONE PROJECT
You are required to generate /simulate a cell phone. The cell phone must have the basic functions of sending and receiving telephone numbers. These numbers should include landline and cell numbers. In addition, include a SMS function of sending and receiving messages.
You will need to do:
1. create a class that contains the following attributes
1.1. ownNumber
1.2. incoming number
1.3. outgoing number
1.4. blocked number
1.5. SMS number
1.6. Engaged
1.7. Time
1.8. Cost_per_minute
(for the I want to do learner ? how about determining if the system is prepaid etc)
You will need to decide what data types you need for the attributes
2. The following methods
2.1. A set and get method for each attribute
2.2. A method that converts the time to hours, minutes and seconds
2.3. A method that determines the cost of the call.
2.4. ToString method
2.5. A print statement about the call, length of call.
3. A main method
That instantiates a Cell phone object and which simulates the front end of cell phone
4. NOTE: Generate random number for the incoming, outgoing - calls, cost and time and the engaged signal
Java school Project
-
- I Bribed Ron With Foundry And All I Got Was This Lousy Title
- Posts: 9387
- Joined: 09 Aug 2002, 02:00
- Location: Locked Down
- Contact:
Java school Project
Jeez, take a look at what we have to do for our Gr 10 Computer studies project.
Want to support my creative work? Drop me a like and subscribe below. It will be greatly appreciated!
Clarke Media - YouTube Channel
Clarke Media - Facebook
Clarke Media - YouTube Channel
Clarke Media - Facebook
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Re: Java school Project
Project wrote: 1.1. ownNumber
1.2. incoming number
1.3. outgoing number
1.4. blocked number
1.5. SMS number
1.6. Engaged
1.7. Time
1.8. Cost_per_minute
Code: Select all
public abstract class Phone
{
private String ownNumber, incommingNumber, outgoingNumber, blockedNumber, SMS number;
private boolean engaged;
private java.util.Date callStart;
private BigDecimal costPerMinute;
}
ii) engaged is digital - either true/false..
iii) Using java.util.Date, calls to a getDuration() type method returns deviation from start to now... or you could store the system time as a long...
iv)BigDecimal... using this wrapper will help in not having to deal with NaN or infinity issues when engaged in double precision math...
Standard practice in any java app.... it's how things work...Project wrote: 2.1. A set and get method for each attribute
Code: Select all
public void setPhoneNumber(String numbr)
{
ownNumber = numbr==null?ownNumber:numbr;
}
public String getPhoneNumber()
{
return ownNumber;
}
Sure..why not... I'm sure the odds are that no codemonkey has ever needed this before, hence its exclusion from the jAPI... man... who teaches this stuff?Project wrote: 2.2. A method that converts the time to hours, minutes and seconds
my favourites being...
someone did their homework... the first is default inherited from Object, but you will almost *always* override in order to make sense of anything... the second you cannot do without if you want the app to run...Project wrote: 2.4. ToString method
3. A main method
....if this doesn't help... give us a shout..
<edit to take care of mental problem... all better now...>
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Code: Select all
private java.util.Date callStart;
MAY THE CHEESE BE WITH YOU!
{PK} Law
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
err..long .. not float ... that's why i said store start time as a long.. but then that's precisely what the java.util.Date class does, while at the same time including all those handy minute/hour/day functions attached along with being implicitly understood by java.util.Calendar...Law wrote:Do u really think that is nessecary. just easier to use Time as a float. then use Time = System.currentTimeMillis();then when the calls finish Time = (System.currentTimeMillis()-Time)/1000. then you got the call length in seconds. Just seems easier.Code: Select all
private java.util.Date callStart;
long just seemed so boring... the API is chock-full of alternmatives to which the average student is never exposed... just seemed a good point at which to start the introduction...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
Code: Select all
public class NooBScanner() implements Serializable
{
public static enum CONSTANT_NOOBS{
LAW("Law", "Master of the Pubic kNights"),
BOB_MUGABE("Satan", "Raging Elton John fan"),
AUSTIN_POWERS("jamin_za", "Brick-less");
private String descript, nick;
CONSTANT_NOOBS(String nck, String descr)
{
nick = nck;
descript = descr;
}
public String getNick()
{
return nick;
}
public String getDescription()
{
return descript;
}
}
//no point instantiating...
private NooBScanner()
{
super();
}
public static boolean isNoob(String posterNick)
{
/*for(CONSTANT_NOOBS cn:CONSTANT_NOOBS.values())
if(cn.getNick().equals(posterNick))
return true;
return false;*/
if(posterNick.toLowerCase().indexOf("law")>=0)
return true;
return false;
}
}
Last edited by rustypup on 01 Sep 2005, 08:45, edited 1 time in total.
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Well create an array of strings as sms' Then you at least have proper msgs
then for numbers use
This generates a random number between (0;1) -> note the round and not square brckets
so you can times it by ten to make a number from 1-9
This makes a String that makes a number
then to select from the array
if you want generate a random number multiply by 26 then add 59(think to get letters
then for numbers use
Code: Select all
Math.random()
This generates a random number between (0;1) -> note the round and not square brckets
so you can times it by ten to make a number from 1-9
This makes a String that makes a number
Code: Select all
String number="";
for(int i=0; i<10; i++)
{
number +=""+((int) Math.random()*10);
}
then to select from the array
Code: Select all
int selectedMsg = (int) Math.random()*messageArray.length()
if you want generate a random number multiply by 26 then add 59(think to get letters
Last edited by Law on 31 Aug 2005, 16:57, edited 1 time in total.
MAY THE CHEESE BE WITH YOU!
{PK} Law
well if you did it my way. you can divide by 60 to get mins and divide by 60 again to get hrs> if you want hrs mins sec
you have total time in secs say int TotSec
mins = TotSecs/60;
hrs = mins/60
then in order
int secs= TotSec-mins*60;
min=mins-hrs*60;
you may think wtf because i'm dividing by 60 then multipling i'll get the same number. But thanks to my good friend integer division it works
you have total time in secs say int TotSec
mins = TotSecs/60;
hrs = mins/60
then in order
int secs= TotSec-mins*60;
min=mins-hrs*60;
you may think wtf because i'm dividing by 60 then multipling i'll get the same number. But thanks to my good friend integer division it works
MAY THE CHEESE BE WITH YOU!
{PK} Law
like int five = 45%10;
you can also use that to get secs and mins
secs = TotSec%60
mins = mins%60
but only after youve calculated the hrs
so TotSecs = 10000;// sec
mins = 166;
hrs = 2;
then secs = TotSecs%60;
mins = mins%60;
IDE = integrated development enviroment
It's the program you code in
you can also use that to get secs and mins
secs = TotSec%60
mins = mins%60
but only after youve calculated the hrs
so TotSecs = 10000;// sec
mins = 166;
hrs = 2;
then secs = TotSecs%60;
mins = mins%60;
IDE = integrated development enviroment
It's the program you code in
MAY THE CHEESE BE WITH YOU!
{PK} Law
- rustypup
- Registered User
- Posts: 8872
- Joined: 13 Dec 2004, 02:00
- Location: nullus pixius demonica
- Contact:
yep... %==modulus == remainder...
but then again,
seriosuly get the latest Eclipse... or netbeans...
also, jdk1.2!?? nooooooo.....
<edit... someday...soon... i'm gonna hurt myself...>
but then again,
seriosuly get the latest Eclipse... or netbeans...
also, jdk1.2!?? nooooooo.....
<edit... someday...soon... i'm gonna hurt myself...>
Most people would sooner die than think; in fact, they do so - Bertrand Russel