• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused about an assignment  RSS feed

 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so in my programming class we have been given an opportunity for extra credit. the directions are probably simple but im not sure what im supposed to do. im not asking for anything considered cheating lol just want to understand what it is im supposed to be trying to do.


Extra Credit
Due: Friday February 3, 5:00PM – Late assignments will not be accepted
5 points
Problem: Using BlueJ and the objects on Moodle, create a picture with your initials (THREE
LETTERS). You are to create a Main class with a main method. The main method should create all of
the objects you need. Make sure you use “Add class from file … “ to add the shapes and canvas
classes to your project.

we have 4 classes that i imported into bluej. canvas, triangles, circles, and rectangles. when i right click canvas and run Canvas getCanvas() it brings up a white window and its blank. i can then use the other classes to add the respective shapes and then alter their size, shape, color, and position. my task is to move them and recolor/resize them to write my initials on screen. im not sure what im being asked to do...
 
Junilu Lacar
Sheriff
Posts: 11490
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're being asked to draw a bunch of different shapes and position them on a Canvas such that they form the three letters that are your initials.
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:You're being asked to draw a bunch of different shapes and position them on a Canvas such that they form the three letters that are your initials.


i mean it says to creat a main method. is this supposed to do something? i can get the initials drawn up. takes ages but is easy. idk why or what i would need a main method for. or what its supposed to be doing
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Mo wrote:i mean it says to creat a main method. is this supposed to do something?

Mike Mo earlier provided instructions wrote:You are to create a Main class with a main method. The main method should create all of
the objects you need
.

Think about, that every Java program needs to have a main method, which is a starting point of application. And the instructions you wrote earlier explicitly tells you what main method supposed to be doing. Have you read them?
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find out about the correct use of a main method here. I would suggest you writePut all the initialisation of the shapes in the mmd class. You will have to contact your instructor and say you were given this advice. Do so now and get agreement that you are allowed to create the shapes from the main method indirectly in the MMD object. What happens if you don't have three initials?
There is a shorter version of that main method which does exactly the same:-
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:. . . every Java program needs to have a main method, which is a starting point of application. . . .
Unfortunately OP is using BlueJ. BlueJ seems to start its own JVM and plugs the user's application into a JVM already running. It has the advantage of making it harder to write procedural code, but it doesn't execute code as a standalone application. So OP might not have seen a main method.
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Liutauras Vilda wrote:. . . every Java program needs to have a main method, which is a starting point of application. . . .
Unfortunately OP is using BlueJ. BlueJ seems to start its own JVM and plugs the user's application into a JVM already running. It has the advantage of making it harder to write procedural code, but it doesn't execute code as a standalone application. So OP might not have seen a main method.


its a common theme that everyone says to run away from BlueJ. seems that its a crap thing to be learning on unfortunately. I learn by example. she teaches by books an simplifying things... I hate that. if the correct way to do things is x then why teach y? being easier isn't a valid reason to me, but to her that's fine. in my eyes I now have to learn the "easy way" then later learn the proper way to do it.

that being said I'm not sure how to explain what I'm doing... so when I run the canvas class in BlueJ, it pulls up a white screen. then I can also right click the shape creators and make new shapes. I think right click those shapes and it pulls up a list of methods that I can use to alter/move the shape. I can use this to write my initials, but for some reason I feel like that's not what I'm supposed to do. I can do that without writing a single line of code using the classes she gave us. this is why I'm confused.

I hope I'm just being a newbie and something that someone on here says will spark my brain and give me that "oh shit I get it now" moment xD
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Mo wrote:so when I run the canvas class in BlueJ, it pulls up a white screen. then I can also right click the shape creators and make new shapes. I think right click those shapes and it pulls up a list of methods that I can use to alter/move the shape. I can use this to write my initials, but for some reason I feel like that's not what I'm supposed to do. I can do that without writing a single line of code using the classes she gave us. this is why I'm confused.


... And you would be 100% correct. You are *not* allowed to do that. You can't directly use the Graphics API available in the Canvas. And you definitely, can't use the code generator from BlueJ. 

The assignment is for you to use a very limited set of graphics, provided by your instructor, to do something a bit more complex.

Henry
 
Junilu Lacar
Sheriff
Posts: 11490
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Mo wrote:I think right click those shapes and it pulls up a list of methods that I can use to alter/move the shape.

You can do basically the same thing via code that you write in your main() method. That's probably what you're supposed to do.
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
Mike Mo wrote:I think right click those shapes and it pulls up a list of methods that I can use to alter/move the shape.

You can do basically the same thing via code that you write in your main() method. That's probably what you're supposed to do.


yeah I was wondering if it was that simple. so I guess I could make a main method that just acts as a run app? my professor isn't getting things through to me very well lol so I'm resorting to learning it all however i can. as this is a new thing for me idk the best way to learn it yet :-/ kind of in a bind.

so i could write code that says "create a new triangle and move it to (x,y) and set color to "color".
 
Junilu Lacar
Sheriff
Posts: 11490
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Mo wrote:so i could write code that says "create a new triangle and move it to (x,y) and set color to "color".

Exactly. How you do that depends on what constructors and methods are available in those shape objects your teacher provided. Whatever you're doing by right clicking and selecting actions from menus that BlueJ presents to you, you'd have to find out how to do that via code that you write in main().
 
Mike Mo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
Mike Mo wrote:so i could write code that says "create a new triangle and move it to (x,y) and set color to "color".

Exactly. How you do that depends on what constructors and methods are available in those shape objects your teacher provided. Whatever you're doing by right clicking and selecting actions from menus that BlueJ presents to you, you'd have to find out how to do that via code that you write in main().


ok awesome. so I'm basically just using a main that i write to call methods already provided by the given classes. well mutators i guess i should say in this case?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!