This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need design help for calculator using AWT only?  RSS feed

 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

My professor gave me assignment to design calculator using AWT first and later design the same with Swing. I am trying to figure out th design first. I come up with few classes:

1) prepareGUI : Which makes GUI frame , buttons and TextField to display result
2) WindowEventManger : To control fram close using windowClosing method
3) ButtonWorking: To perform work on Button event
4) My Exception class: for customized exception
5) CalculatorAWT: class to call prepareGUI , WindowEventManger , ButtonWorking using its constructor
6) Main class Class where main method is.

Is it correct or am i missing something? This is my first project so dont have much idea about the design. Right now i am not allowed to use any frame Layout. I have to use the same with Swing.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12529
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
something to consider...you should learn to separate what your program DOES from what it LOOKS like. So when you first approach a project, don't think about graphic components at all. Think about what it needs to do. figure out that stuff first, before you start worrying about how to make it pretty on the screen.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I'm not sure what you mean by "frame layout", I will say that IMO any course that starts by teaching AWT in 2014 may be a waste of time.

Apart form that, the question "Is it correct or am i missing something?" is probably meaningless - there are any number of way to solve this, and it sounds like you're not far enough down the road to be expected to come up with a perfect design.
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
something to consider...you should learn to separate what your program DOES from what it LOOKS like. So when you first approach a project, don't think about graphic components at all. Think about what it needs to do. figure out that stuff first, before you start worrying about how to make it pretty on the screen.


Okies Thanks... This is the simple calculator which does following task:

1) Add 2) Subtract 3) Multiply 4) Divide 5) Percentage 6) SqRoot 7) clear all 8) clear one number 9) equal 10) square 11) 0-9 numbers

What else i need s to be think? Sorry for asking simple question but i am new to this..

While I'm not sure what you mean by "frame layout", I will say that IMO any course that starts by teaching AWT in 2014 may be a waste of time.


Actually he wanted to each event handling and requirement of swing as compare to AWT

Apart form that, the question "Is it correct or am i missing something?" is probably meaningless - there are any number of way to solve this, and it sounds like you're not far enough down the road to be expected to come up with a perfect design


Yes sir .. I am only 1.5 month old in this technology. Could you please give me some suggestion for improvement ?
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can you guys suggest me on my above asked query??
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred ahs already given you useful suggestions.
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys, Thanks for the response.. I have completed my calculator assignment using AWT but i think i missed several things and that was not as per good design.

Now i am working using SWING and want to follow proper guidelines.

I thought about it and found that following things are required:

Input: Integer , Float and Operator

Display: int , float and warnings

Operators are of 2 types:

1) Binary which takes 2 operand to perform some operations like + , / ,* , -
2) Uniary which takes single operand like 1/x , sqroot, x^2

Warnings: divide by 0 , sqroot of negative number , Illegeal format of input etc..

I also gave some input to the calculator got following result:

Input Operator Input Result
1 + 1 2
1 / 1 1
10 / 3 3.33
1 / 0 Cannot divide by 0
-5 sqRoot 2.23i

Can you please suggest more?
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tushar Goel wrote: . . . I thought about it and found that following things are required:

Input: Integer , Float and Operator

Display: int , float and warnings . . .
You should have that all working with no GUI at all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!