Results 1 to 7 of 7

Thread: two questions

  1. #1
    h_a25 is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default two questions

    hey, how're u guys?

    my instructor gave us an assignment and i really tried so hard but i couldn't write the codes well :/
    the first task is about an IntegerSet class and the second about drawing a cube
    here's the test class

    public class IntegerSetTest {

    public static void main(String[] args) {

    IntegerSet s = new IntegerSet();
    System.out.println(" s = " + s);
    s.addElements(2);
    s.addElements(20, 10, 100);
    s.addElements(13, 20);
    System.out.println(" s = " + s);

    IntegerSet s1 = new IntegerSet(0, 3, 6);
    s1.addElements(12, 20, 2000, 30, 31, 32, -11);
    System.out.println(" s1 = " + s1);

    IntegerSet s2 = new IntegerSet(10, 3, 16, 11, 21, 33, 99);
    System.out.println(" s2 = " + s2);

    if(s2.isElement(11))
    System.out.println(" 11 belongs to s2");
    else
    System.out.println(" 11 does not belong to s2");

    IntegerSet s3;
    s3 = s1.union(s);
    System.out.println(" s1 Union s = " + s3);
    s2 = s1.intersection(s);
    System.out.println(" s1 Intersection s = " + s2);

    s2.addElements(2, 11, 7, 1100);
    System.out.println(" s2 = " + s2);
    s2.removeElement(20);
    System.out.println(" s2 = " + s2);

    }

    }
    and here's the outputs pic
    two questions-untitled.png
    or u can download them from here http://www.mediafire.com/?5c1vm7g0i5jv0s5
    Last edited by h_a25; 03-25-2012 at 10:06 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: two questions

    Quote Originally Posted by h_a25 View Post
    my instructor gave us an assignment and i really tried so hard but i couldn't write the codes well :/

    the first task is about an IntegerSet class and the second about drawing a cube
    here's the test class

    Java Code:
    public class IntegerSetTest {
    
    	public static void main(String[] args) {
    		
    		IntegerSet s = new IntegerSet();
    		System.out.println(" s = " + s);
    		s.addElements(2);
    		s.addElements(20, 10, 100);
    		s.addElements(13, 20);
    		System.out.println(" s = " + s);
    		
    		IntegerSet s1 = new IntegerSet(0, 3, 6);
    		s1.addElements(12, 20, 2000, 30, 31, 32, -11);
    		System.out.println(" s1 = " + s1);
    		
    		IntegerSet s2 = new IntegerSet(10, 3, 16, 11, 21, 33, 99);
    		System.out.println(" s2 = " + s2);
    		
    		if(s2.isElement(11))
    			System.out.println(" 11 belongs to s2");
    		else
    			System.out.println(" 11 does not belong to s2");
    		
    		IntegerSet s3;
    		s3 = s1.union(s);
    		System.out.println(" s1 Union s = " + s3);
    		s2 = s1.intersection(s);
    		System.out.println(" s1 Intersection  s = " + s2);
    		
    		s2.addElements(2, 11, 7, 1100);
    		System.out.println(" s2 = " + s2);
    		s2.removeElement(20);
    		System.out.println(" s2 = " + s2);
    		
    	}
    
    }


    Do you have a specific question that we can answer?

  3. #3
    h_a25 is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: two questions

    well not really but the first task i should write IntegerSet class makes the IntegerSetTest class works and give the output in the pic icontains a constructor takes ellipsis parameter and the functions addElements, union and intersection
    and the second task i should write a program to draw a cube like the one showing in the pic

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: two questions

    Quote Originally Posted by h_a25 View Post
    well not really but the first task i should write IntegerSet class makes the IntegerSetTest class works and give the output in the pic icontains a constructor takes ellipsis parameter and the functions addElements, union and intersection
    and the second task i should write a program to draw a cube like the one showing in the pic
    OK, well best of luck with this project. Please come on back if you get stuck and have any specific questions that we can help you with.

  5. #5
    h_a25 is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: two questions

    thank u Fubarable
    wish someone else can help me :D

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: two questions

    Quote Originally Posted by h_a25 View Post
    thank u Fubarable
    wish someone else can help me :D
    We'd love to, but you've yet to ask an answerable question, and without a question, all this thread will consist of will be you expressing your frustration and us telling you that there's nothing we can do. No one is of course going to do this for you, and we'd love to help explain things and clarify misconceptions, but we have no idea where your problem is, what you understand, what you don't understand, etc. If you're totally lost, please look over this link -- So, You Need to Write a Program but Don't Know How to Start

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default Re: two questions

    That cube drawing doesn't look like it's a perspective projection; if it's an orthogonal projection it's easy: draw two squares and four lines between the corner points. For that set problem you can use a Set<Integer> or a BitSet (the API documentation is your friend).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. 3 questions
    By silverglade in forum New To Java
    Replies: 11
    Last Post: 05-09-2011, 03:17 PM
  2. questions regarding XML
    By Sparky in forum New To Java
    Replies: 4
    Last Post: 02-01-2011, 07:10 PM
  3. I have 2 questions =P
    By santa in forum New To Java
    Replies: 4
    Last Post: 01-19-2011, 05:35 PM
  4. Questions
    By Csharks in forum New To Java
    Replies: 8
    Last Post: 01-19-2011, 04:11 AM
  5. questions for 1yr exp
    By rahaman.athiq in forum Java Servlet
    Replies: 2
    Last Post: 11-26-2008, 01:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •