• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Help with Model View Control concept

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i'm doing a second year java programming course...

my current assingment requires the use of multiple java files conforming to a java model view control concept...

specs of the assingment is here

http://www.comp.mq.edu.au/units/comp229/Assignment/assign2/Assignment2.pdf

the provided src files are here

http://www.comp.mq.edu.au/units/comp229/Assignment/assign2/src.zip

i've tried 4 days on this assingment.. only concern would be how to store data into a data structure and then make multiple instances so it can create multiple instances of shapes...

i have not place the code inline as there is quite alot

my code is here
http://members.optusnet.com.au/worlok/shape.rar

i've tried using a list and hashmap but i really have no idea

some help please... many thanks

i came from a c++ background
 
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, since this is 8% of your final grade I have deliberately been a little vague...

[EDIT: I just read further down and saw the large amount of code you have been given so far. I'm leaving my original post in tact but of course you should conform with all the requirements stated (e.g. the IShape interface) or you will have problems later.]

To start with I would create a class called Shape to represent the shape data. Fields should include shapetype, colour, x, y, etc (note NOT the shape ID). You will need to make two constructors for this class since regular shapes have 6 properties, and line shapes have 7. When you have done this you should be able to write some code like:


Instead of hard coding the colour and values like I have you will read them from the file.

When you have created the shape instance, add them to a HashMap like so:

map.add(t2_1, s1);

Again, instead of hard-coding the "t2_1" you will read it from the file.

Hope this helps a little.

[ April 21, 2005: Message edited by: S Gray ]
[ April 21, 2005: Message edited by: S Gray ]
reply
    Bookmark Topic Watch Topic
  • New Topic