PLEASE HELP! I have this assignment (see below) and have a solution for it using synchronized lists. However my code does not compile successfully and I need some help fixing it. Please be patient with me as I am a slow learner and new to synchronized
thread java programming. Also I have a limited time window to resolve this. My source files are also enclosed. This is the error I get:
C:\java\TMobile>javac -Xlint TMobileSubscriber.java
TMobileSubscriber.java:34: cannot find symbol
symbol : variable Subscriber
location: class TMobileSubscriber
ArrayList Subscribers = new ArrayList(Subscriber);
^
TMobileSubscriber.java:37: warning: [unchecked] unchecked conversion
found : java.util.ArrayList
required: java.util.List<T>
List subscriberList = Collections.synchronizedList(Subscribers);
^
TMobileSubscriber.java:37: warning: [unchecked] unchecked method invocation: <T>
synchronizedList(java.util.List<T>) in java.util.Collections is applied to (java
.util.ArrayList)
List subscriberList = Collections.synchronizedList(Subscribers);
^
.\Subscriber.java:339: reached end of file while parsing
} /* class Subscriber extends Runnable */
^
TMobileSubscriber.java:58: non-static method wait(long) cannot be referenced fro
m a static context
wait(60000);
^
.\Subscriber.java:28: cannot find symbol
symbol : variable Subscriber
location: class Subscriber
this.subscriberList = Collections.synchronizedList(new ArrayList(Subscri
ber)) ;
^
.\Subscriber.java:28: warning: [unchecked] unchecked conversion
found : java.util.ArrayList
required: java.util.List<T>
this.subscriberList = Collections.synchronizedList(new ArrayList(Subscri
ber)) ;
^
.\Subscriber.java:28: warning: [unchecked] unchecked method invocation: <T>synch
ronizedList(java.util.List<T>) in java.util.Collections is applied to (java.util
.ArrayList)
this.subscriberList = Collections.synchronizedList(new ArrayList(Subscri
ber)) ;
^
.\Subscriber.java:66: cannot find symbol
symbol : variable newSubscriber
location: class Subscriber
if (!subscriberList.contains(newSubscriber)) {
^
.\Subscriber.java:67: cannot find symbol
symbol : variable newSubscriber
location: class Subscriber
subscriberList.add(newSubscriber);
^
.\Subscriber.java:97: cannot find symbol
symbol : constructor Subscriber()
location: class Subscriber
Subscriber subscriber = new Subscriber();
^
.\Subscriber.java:100: incompatible types
found : java.lang.Object
required: Subscriber
subscriber = subscriberList.get(i);
^
.\Subscriber.java:135: cannot find symbol
symbol : constructor Subscriber()
location: class Subscriber
Subscriber subscriber = new Subscriber();
^
.\Subscriber.java:138: incompatible types
found : java.lang.Object
required: Subscriber
subscriber = subscriberList.get(i);
^
.\Subscriber.java:174: cannot find symbol
symbol : constructor Subscriber()
location: class Subscriber
Subscriber subscriber = new Subscriber();
^
.\Subscriber.java:177: incompatible types
found : java.lang.Object
required: Subscriber
subscriber = subscriberList.get(i);
^
.\Subscriber.java:221: cannot find symbol
symbol : constructor Subscriber()
location: class Subscriber
Subscriber subscriber = new Subscriber();
^
.\Subscriber.java:224: incompatible types
found : java.lang.Object
required: Subscriber
subscriber = subscriberList.get(i);
^
.\Subscriber.java:328: incompatible types
found : java.lang.Object
required: Subscriber
currentSubscriber = subscriberList.get(i);
^
15 errors
4 warnings
C:\java\TMobile> THANKS A LOT
ASSIGNMENT DETAILS:
Write a small java program that will store mobile subscribers in memory and allow a few operations on the subscribers. Each subscriber consists of a phone number, name, balance in cents, and decrement rate. A decrement rate is a number which indicates how many cents a subscriber is charged per minute. A phone number is a 10 digit number. In addition to the operations below, there should also be seperate thread running that prints the phone number and name of all the currently stored subscribers to standard out every minute.
The following operations should be supported:
1. Adding a new Subscriber:
a. This operation should accept all the attributes of a subscriber.
b. This operation should create the subscriber and save it.
c. This operation should fail with error code 100 and error message “Invalid subscriber definition!” if the phone number is not valid.
d. This operation should fail with error code 400 and error message “Subscriber already exists!” if the phone number corresponds to an existing subscriber.
2. Retrieving an existing Subscriber:
a. This operation should accept a phone number and return the associated subscriber.
b. This operation should fail with error code 200 and error message “Subscriber does not exist!” if the phone number does not correspond to an existing subscriber.
3. Removing an existing Subscriber:
a. This operation should accept a phone number and remove the associated subscriber.
b. This operation should fail with error code 200 and error message “Subscriber does not exist!” if the phone number does not correspond to an existing subscriber.
4. Update an existing Subscriber’s balance:
a. This operation should accept a phone number and an increment amount.
b. This operation should adjust the subscriber’s balance with the given amount.
c. This operation should fail with error code 200 and error message “Subscriber does not exist!” if the phone number does not correspond to an existing subscriber.
d. This operation should fail with error code 300 and error message “Balance is out of range!” if the new balance is less than $0 or more $1000.
5. Retrieve an existing Subscriber’s balance:
a. This operation should accept a phone number.
b. This operation should return both the subscriber’s balance in cents and how many minutes the subscriber can use before his balance is expired.
c. This operation should fail with error code 200 and error message “Subscriber does not exist!” if the phone number does not correspond to an existing subscriber.
MAIN CLASS:
THREAD CLASS:
OTHER CLASSES: