Using a constructor inside of main [on hold]
I am in need of some help for my homework
In the same bluej project, create a new class named TestPickle with a main
method. Do the following in that main method.
Create a new Pickle object named p1 using the no-parameter constructor.
Create a new Pickle object named p2 using the parameter constructor. Pass
the values 10 and "Gherkin" as arguments in the constructor.
Set p1's type to "Sweet" using the appropriate mutator.
Set p2's weight to 6 using the appropriate mutator
I have already finished the first part of this assignment and I am now
stuck on this part. I need help with how to make the constructor within
the main method. Any input would be greatly appreciated.
Here is the code I have so far,
public class TestPickle {
public ex(int p1, int p2)
{
this.p1 = p1
this.p2 = p2
}
public static void main(String[] args)
{
System.out.printf("\t%-12s%-12s\n", "Type", "Weight");
System.out.printf("\t%-12s%-12s\n", p1.getType(), p1.getWeight());
System.out.printf("\t%-12s%-12s\m", p2.getType(), p2.getWeight());
}
}
The printf functions are there as described in the assignment
No comments:
Post a Comment