Programming Fundamentals IT 108
Popular in Course
Popular in Information technology
This 5 page Class Notes was uploaded by Adonis Nader on Monday September 28, 2015. The Class Notes belongs to IT 108 at George Mason University taught by Irene Bruno in Fall. Since its upload, it has received 35 views. For similar materials see /class/215221/it-108-george-mason-university in Information technology at George Mason University.
Reviews for Programming Fundamentals
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/28/15
T108 April 9 2009 Problem Create an 00 solution to calculate the amount of fencing needed to surround a rectangular yard The minimum dimensions the company can handle is 500 feet 0 800800 64000 6 stops working correctly 0 What to limit any rectangle to 800 o Instance Variables 0 Gets its very own copy of everything in the class 0 Rectangle yard ew RectangleO Creates Instance yard and calls constructor Constructor Rectangle setLengthO getperimetero getLengthO getWidthO setenghtmtb 39e 39quot Validating setWidthintboolean Process 0 Activity involves of the values in one object in order to solve the problem 0 Anything that has multiple job is taken care of Rectangle Code item Last Class public class RectangleClassDef private int length private int width public int getLengthO return length public int getWidthO return width public void setLengthint l length l T108 April 9 2009 public void setWidth int w width w public int perimeter 0 return 2 length 2 width public int area 0 return length width assign it to it to Changes to Class Code class Rectangle private int length private int width public int getLength 0 return length I input from user public int getWidth 0 return width width dimension of valid rectangle public Boolean setLengthint L ifLgtoampampLltsoo G length L return true else return false public Boolean setWidthint w if wgt0ampampwlt800 width w return true else T108 April 9 2009 return false public length L public int perimeter 0 return 2 length 2 width public int area 0 return 2 length 2 public void setLengthint l length l public void setWidthint w width w Changes to Class Code import javaxswingJOptionPane public class Fence public static void main String args rectangle yard new Rectangle int yardLengt h yardWidt h do yardLength lntergerparaselntJOptionPaneshowlnputDialog Enter length of yard while lyardsetLengthyardLength yardWidth lntergerparaselntJOptionPaneshowlnputDialog Enter width of yard quot while lyardsetLengthyardWidth yardWidth lntergerparaselntJOptionPaneshowlnputDialog ERROR Enter width of yard quotD JOptionPaneshowMessageDialognull A yard with length yardgetLength feet and widthquot yardgetWidth feet requires quot feet requiresquot yardpermiter feet of fencing quot Changes to Class Code Create and Fill an Obie import javaxswingJOptionPane public class Fence public static void main String args Rectangle mWard input 0 JOptionPaneshowMessageDialognull A yard with length yardgetLength feet and widthquot yardgetWidth feet requires quot feet requiresquot yardpermiter feet of fencing April 2 2009 0 0 solulion l Wholislne problem 2 Wholislne Objecl Procedural Info oul 3 Objecl ChOlT relurn vcrlue ccesslgel implemenlcrlion gequmeso Soccer Lecrue l lnpul info M Soccerjcrvcr Pl 0 l Dolor in one objecl 9 clossdefincrlion Access from objecl Oulpul home and slcrls lnformcrlion in orcrmeler Mucrlcrlorlseln Creole objecl lnpul leomNcrme lnpul inlo Objecl Tecrmjcrvcr o Dolo i Will be unique for each objecl l lnslonce vorioble b Melnods 39 Access Mulolor Conslruclor iv Speciol purpose Speciol Purpose 1 Operolion inslonce dolo lt April 2 2009 public class Team private String name private int won private int lost public String Mistakel return name public int getWon public void setNameString name return won name name public int getLost return lost Problem is one variable is representing public void setNameString n for two things name n Same name cant do both public void setWon int W Local over rides it you get a team won W without a name public void setLost int I lost l Public int stats return 100 won won lost Creates Teamname myTeam Falcons Public class soccer Public static void main String args Team myTeam newTeam Team another newTeam teamName JOption PaneSnowlnputDialog Namez
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'