Java Programming Using seriazation in java Create a class named CellPhone implementing that has 4 data members - load, talkTime (min), ratePerMinute, ratePerText . Define 3 constructors - one is the default constructor , second a constructor that would initialize all the attributes , and third is a constructor that allows the user to initialize all the attributes except the load, instead, directly set load to 300. Also, define getter and setter methods for all attributes.Implement these methods : (1) callCost that would return the total cost of the call based on the parameter 'duration' (2) canCall method that returns true if parameter 'duration' (in min) is less than or equal to the available 'talkTime' and you have enough load to complete the call. [HINT: call callCost method and deduct the talkTime] (3) isLowBat method that returns true if the talkTime is equal to zero (4) canText method that reduces the load by its ratePerText and returns true if text is successfully sent and it consumes 0.05 minute of the talkTime and (5) toString method that would print the remaining load balance (6) To implement serialization, add writeObject and readObject methods In a separate class TestCellphone, write a main method (refer to TestPerson class) that works the same as TestPerson class.
Java Programming
Using seriazation in java
Create a class named CellPhone implementing that has 4 data members - load, talkTime (min), ratePerMinute, ratePerText .
Define 3 constructors - one is the default constructor , second a constructor that would initialize all the attributes , and third is a constructor that allows the user to initialize all the attributes except the load, instead, directly set load to 300.
Also, define getter and setter methods for all attributes.Implement these methods :
(1) callCost that would return the total cost of the call based on the parameter 'duration'
(2) canCall method that returns true if parameter 'duration' (in min) is less than or equal to the available 'talkTime' and you have enough load to complete the call. [HINT: call callCost method and deduct the talkTime]
(3) isLowBat method that returns true if the talkTime is equal to zero
(4) canText method that reduces the load by its ratePerText and returns true if text is successfully sent and it consumes 0.05 minute of the talkTime and
(5) toString method that would print the remaining load balance
(6) To implement serialization, add writeObject and readObject methods
In a separate class TestCellphone, write a main method (refer to TestPerson class) that works the same as TestPerson class.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images