Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:04:51+00:00 2026-06-13T19:04:51+00:00

So a section of my assignment is to make a triangle class to be

  • 0

So a section of my assignment is to make a triangle class to be linked to various buttons…but I’m not sure how to make one in eclipse. The specific instructions say this:

Create a triangle class

  1. Data fields: Point[] coords;
  2. constructors
  3. Implement all abstract methods defined in superclass
  4. Getters and setters for each data field
  5. Override public void paint(Graphics arg0) method

I have everything set up in the other classes..except for the triangle class. I’m confused on how to create a triangle using an array of points…Do I need to use Point x,y or somehow store 3 (x,y) coordinate pairs in that one array variable coords? I imagine to create it you would use drawPolygon…but I’m not certain. Any tips?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:04:51+00:00Added an answer on June 13, 2026 at 7:04 pm

    Here is an example class for Triangle

    public class Triangle {
    
      private Point[] coords;
    
      // Null object constructor
      public Triangle() {
        this.coords = null;
      }
    
      // Constructor with point array
      public Triangle(Point[] coords) {
        this.coords = coords;
      }
    
      // Constructor with multiple points
      public Triangle(Point a, Point b, Point c) {
        this.coords = new Point[3];
        coords[0] = a;
        coords[1] = b;
        coords[2] = c;
      }
    
      // The actual paint method
      public void paint(Graphics arg0) {
        // Setup local variables to hold the coordinates
        int[] x = new int[3];
        int[] y = new int[3];
        // Loop through our points
        for (int i = 0; i < coords.length; i++) {
            Point point = coords[i];
            // Parse out the coordinates as integers and store to our local variables
            x[i] = Double.valueOf(point.getX()).intValue();
            y[i] = Double.valueOf(point.getY()).intValue();
        }
        // Actually commit to our polygon
        arg0.drawPolygon(x, y, 3);
      }
    }
    

    Not sure what exactly this class is supposed to be extending, so nothing is marked as an override or anything, and it is missing setters and accessors, but you should be able to make it work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with section 4 of the stanford iphone class on assignment 1b.
Alright, I might make this confusing, but hopefully not. So I have a UITableView
I've just completed the coding section of simple homework assignment for my C++ class.
My assignment is to make a class that acts like a standard library List
Sample XML: <assignments> <assignment id=911990211 section-id=1942268885 item-count=21 sources=foo> <options> <value name=NumRetakes>4</value> <value name=MultipleResultGrading>6</value> <value
Ok so for an assignment we have to make our first program. Mine is
I have a homework assignment. I'm not looking for anyone to do the work
I am working on a section of code for an assignment I am doing
For a class assignment, I'm required to write an object to a file. Our
In my assembly language class, our first assignment was to write a program to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.