SquareAntiprism ex1 = new SquareAntiprism("Small Example", 1.25) Note that although String and numeric literals are used for the actual parameters (orĪrguments) in these examples, variables of the required type could have been used instead of The constructor should increment the class variable count each time a SquareAntiprism isīelow are examples of how the constructor could be used to create SquareAntiprism objects. Using the statement label = labelIn use the statement setLabel(labelIn) Should be called since they are checking the validity of the parameter. Parameters directly to the fields, the respective set method for each field (described below) Parameters (see types of above) representing the label and edge. (2) Constructor: Your SquareAntiprism class must contain a public constructor that accepts two SquareAntiprism class, and these should be the only instance variables (fields) in the class.Ĭlass Variable - count of type int should be private and static, and it should be initialized to Variables should be private so that they are not directly accessible from outside of the String to "" and the double variable to 0 in their respective declarations. (1) Fields: Instance Variables - label of type String and edge of type double. SquareAntiprism objects for equality as well as a method required by Checkstyle.ĭesign: The SquareAntiprism class has fields, a constructor, and methods as outlined below. And finally, this class provides a method that JUnit will use to test SquareAntiprism objects that have been created, as well appropriate static methods to access and SquareAntiprism class includes a one static field (or class variable) to track the number of Object, and a method to provide a String value that describes a SquareAntiprism object. The SquareAntiprism class also includes methods to set and get each of theseįields, as well as methods to calculate the height, surface area, and volume of a SquareAntiprism Requirements: Create a SquareAntiprism class that stores the label and edge (edge must be nonnegative, >= 0). Project: Square Antiprism with JUnit Tests – Part 1 of 5 Triangle sides closed by two square caps with edge length a. You will then be able to run the test file by clicking the JUnit run button on the OpenĪ uniform Square Antiprism is a Square Antiprism composed of a sequence of eight equilateral In source File category, you should right-click on the file and select “Mark As Test” from the rightclick menu. When it is created you should see it in the Test Files category. Project is open, your test file, SquareAntiprismTest.java, will be automatically added to the project SquareAntiprism.java file, you should create a jGRASP project and add your SquareAntiprism.javaįile you should see it in the Source Files category of the Project section of the Browse tab. You should create a new folder to hold the files for this project. Note that there is no requirementįor a class with a main method in this project. More test methods for each method in the SquareAntiprism class. SquareAntiprism object and (2) SquareAntiprismTest class is a JUnit test class which contains one or Overview: This project consists of two classes: (1) SquareAntiprism is a class representing a
0 Comments
Leave a Reply. |