Classes and methods

 

3. Write a class called HW6cClass, which creates an object which generates a class with the information from the table shown (attendance sheet). Note you can use the types, int, float, String, and boolean and arrays as necessary. It is up to you to choose which. Write a function called HW6C, which creates an instance of this class HW6CClass holding the info below, then returns it. Note: Marked is either yes or no. Attribute names are case sensitive so use Name as printed, not name as you might generally use for a field.
4. Write a class called HW6dClass which maintains the information from the table shown. Note you should use the types int, float, String, and boolean. In the template function HW6D() in create an ArrayList of HW6dClass (i.e ArrayList myTable) . After allocating the arrayList, create four instances of the HW6dClass class that holds the information in the table above. PUT YOUR OWN NAME in as the last name in the list of HW6dClass(s) (indicated in the table). The HW6D function should return this array. [10 Marks ]
5. Write a class called HW6eClass given the table header below. This class should have a public method called myValuePlusVAT. This method should take no arguments and return a float. The return value multiplies the number of items in the basket by the field price Then adds Value Added Tax (VAT) which is currently 20%. Note a quick way to compute value adding tax (VAT) to a price p is to multiple p by 1.2 Create a method HW6e which returns an instance of this class with the values in the table below. [ 10 Marks ]
6. There are two classes below, one which implements the class BurgerMenu and the other which provides a basic Button. Create a new class called Common, which uses as many features of Button and BurgerMenu as possible. Use the template function HW6F to return an instance of Common. All numbers in the returned instance should contain three(3) and all strings “EMPTY”. The instance’s values don’t matter, but the field names (also known as attribute names) should be spelled exactly as the original classes. Finally, change the class Button and the class BurgerMenu to be subclasses of Common, removing the fields inherited from the Commons superclass. [ 20 Marks]

class Button
{
String title ;
int hoz, vert ;
int sizedOpen;
int sizeClosed ;
float penThickness;
}
class BurgerMenu
{
String title ;
int hoz, vert ;
int sizedOpen;
int totalWidth ;
int process;
}

7. Take the class given and re-write it in a fully encapsulated manner. Keep the name (HW6GStarterClass ) in the function HW6G return a new instance of this class. The values in the fields are not tested. You can use “empty” for strings and 3 for numeric fields. [ 20 Marks]

class HW6GStarterClass
{
// this class represents a record of a file on a drive
private String trackTitle ;
private String album ;
private String artistName ;
private int trackLength ;
private String trackURL ;
private int numberOfPlays ;
private int numberOfLikes ;
private int trackRateing;
};

8. Write a class called HW6HClass as a sub-class of Object which implements the Interface Assessment6.CW6HInterface code below. Note that there is no need to declare this interface; just implement Assessment6.CW6HInterface. In this class the implementation of getHeight() should return 40 , and getWidth() returns 80. Use the function called HW6H( ) with returns an instance of this class. Note the class can be called anything; it should have a field called message of type String. This field should contain the text “Submit” and should return this value via the getMessage() method. Note you may have to fully specify using uk.ac.northumbria.dalton.Assessment6.CW6HInterface not just Assessment6.CW6HInterface.

CW6HInterface
{
int getHeight();
int getWidth();
String getMessage();
}

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Our customer support team is here to answer your questions. Ask us anything!