Skip to content

Commit

Permalink
Some changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqg5325 committed Sep 6, 2018
1 parent cc0c4a7 commit e592126
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 91 deletions.
2 changes: 1 addition & 1 deletion ExchangeList.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void Delete(Exchange e)
}
temp = temp.next;
}
throw new RuntimeException("Error - Exchange " + e.id + " is not present in list");
throw new RuntimeException("Error - Exchange with identifier " + e.id + " is not present in the list");
}

public int size()
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
all:
javac assn3checker.java
javac Myset.java
javac MobilePhone.java
javac MobilePhoneSet.java
javac Exchange.java
javac ExchangeList.java
javac RoutingMapTree.java
javac *.java
java assn3checker

clean:
find . -name "*.class" -type f -delete
rm *.class
clear
2 changes: 1 addition & 1 deletion MobilePhone.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public void switchOff()
public Exchange location()
{
if(status) return exchange;
throw new RuntimeException("Error - Mobilephone " + number() + " is switched off");
throw new RuntimeException("Error - Mobile phone with identifier " + number() + " is currently switched off");
}
}
13 changes: 7 additions & 6 deletions MobilePhoneSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ public MobilePhoneSet()

public void Insert(MobilePhone mobile)
{
mobileSet.Insert(mobile);
try { mobileSet.Insert(mobile); }
catch(RuntimeException ex)
{
throw new RuntimeException("Error - Mobile phone with identifier " + mobile.number() + " is already present in this resident set");
}
}

public void Delete(MobilePhone mobile)
{
try
{
mobileSet.Delete(mobile);
}
try { mobileSet.Delete(mobile); }
catch(RuntimeException e)
{
throw e;
throw new RuntimeException("Error - Mobile phone with identifier " + mobile.number() + " is not present in this resident set");
}
}

Expand Down
22 changes: 3 additions & 19 deletions Myset.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public boolean IsMember(Object o)

public void Insert(Object o)
{
if(IsMember(o)) return;
if(IsMember(o)) throw new RuntimeException("Error - Object is already in the set");
Node tmp = new Node(o);
if(head==null)
{
Expand Down Expand Up @@ -77,7 +77,8 @@ public Myset Union(Myset a)
temp = a.head;
while(temp != null)
{
if(!union.IsMember(temp.obj)) union.Insert(temp.obj);
try { union.Insert(temp.obj); }
catch(RuntimeException ex) {}
temp = temp.next;
}
return union;
Expand Down Expand Up @@ -119,21 +120,4 @@ public Object[] getItems()
}
return objs;
}

/*public static void main(String[] args)
{
Myset a = new Myset();
System.out.println(a.IsEmpty());
a.Insert(1529); a.Insert(99); a.Insert(455); a.Insert(99);
System.out.println(a.IsEmpty());
System.out.println(a.size());
System.out.println(a.IsMember(455));
System.out.println(a.getItems()[1]);
//a.Delete(15);
System.out.println(a.getItems()[1]);
Myset b = new Myset(); //b.Insert(99); b.Insert(656); b.Insert(34); b.Insert(1529);
Myset c = b.Union(a);
c = b.Intersection(a);
System.out.println(c.size());
}*/
}
Loading

0 comments on commit e592126

Please sign in to comment.