CS288 Lab Exercise 1. UniS Open PersonGui Files Go to Course web site for PersonGui source files

Slides:



Advertisements
Similar presentations
Jump to Contents Instructor Tutorial essignments.com Paperless assignment submission system.
Advertisements

Introduction to Programming Java Lab 1: My First Program 11 January JavaLab1.ppt Ping Brennan
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Customizing the MOSS 2007 Search Results November 2007 Rafael Perez.
BAVWEB 2012 Complete Manual Prerequisite: BAV theory, experience with any of the older tools.
Windows XP Basics OVERVIEW Next.
Fall 2007ACS-1903 BlueJ Ron McFadyen Lab 1: Using BlueJ at UofW The purpose of this lab is to give you some experience with BlueJ. Over the course of the.
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
How to Compile Java in Windows. click start then run.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
Adding Websites to a Folder  Putting sites into an already existing folder Putting sites into an already existing folder  Adding an image on the icon.
HTML, Third Edition--Illustrated Complete 1 HTML – Third Edition Illustrated Complete Unit I Designing Web Pages.
Towson University COSC 236
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Web Design Using HTML Codes. WHAT DO I NEED TO BEGIN DESIGNING A HOME PAGE? 1.YOU NEED A FOLDER (also called a DIRECTORY) You should set up a folder or.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Web Technologies Website Development Trade & Industrial Education
Using the FOCUS Web Site Teacher’s Desk. Topics Covered in this Presentation n Accessing the FOCUS Web site n Importing and Creating Classes n Adding.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Website Development with Dreamweaver
HTML, Third Edition--Illustrated Brief 1 HTML, Third Edition Illustrated Brief Unit D Adding Graphics and Multimedia.
Mail merge I: Use mail merge for mass mailings Perform a complete mail merge Now you’ll walk through the process of performing a mail merge by using the.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
HTML Hyper Text Markup Language. What is an HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup.
1 Working with MS SQL Server Textbook Chapter 14.
Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.
Go to your school’s web locker site school name.schoolweblockers.com) Your user name is the first letter of your first name, the first four.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Updating the Laboratory Website. Useful Info Address: Everything is saved in the desktop.
0 eCPIC User Training: Resource Library These training materials are owned by the Federal Government. They can be used or modified only by FESCOM member.
Active-HDL Interfaces Debugging C Code Course 10.
Creating and running a Java program. Eclipse Interactive Development Environment (IDE)  Eclipse is an Interactive Development Environment (IDE) for Java.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Dr. Gina Green Class Setup.
Go to your school’s web locker site Your user name is the first letter of your first name, the first four letters of.
11/25/2015Slide 1 Scripts are short programs that repeat sequences of SPSS commands. SPSS includes a computer language called Sax Basic for the creation.
1 Installing Java on Your PC. Installing Java To develop Java programs on your PC: Install JDK (Java Development Kit) Add the directory where JDK was.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
1 Project 3 String Methods. Project 3: String Methods Write a program to do the following string manipulations: Prompt the user to enter a phrase and.
BUILDING A WEB PAGE BASIC HTML CODING. We first open notepad to start to build our web page. We enter the code at the beginning. And then we write below.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Microsoft Office 2008 for Mac – Illustrated Unit D: Getting Started with Safari.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Creating a Google Site For a Digital Portfolio Purpose.
MySQL Getting Started BCIS 3680 Enterprise Programming.
Instructional Design Center Embedding Google Documents in Blackboard.
DEVRY CIS 170 C I L AB 1 OF 7 G ETTING S TARTED Check this A+ tutorial guideline at
Excel Tutorial 8 Developing an Excel Application
2 At the top of the zone in which you want to add the Web Part, click Add a Web Part. In the Add Web Parts to [zone] dialog box, select the check box of.
2 At the top of the zone in which you want to add the Web Part, click Add a Web Part. In the Add Web Parts to [zone] dialog box, select the check box of.
Some Tips for Using Eclipse
Object-Oriented Software Engineering
How to Run a Java Program
Integrating JavaScript and HTML
CS288 Lab Exercise 3.
CS288 Lab Exercise 1.
How to Run a Java Program
CS115 HOW TO INSTALL THE JAVA DEVELOPMENT KIT (JDK)
CS288 Lab Exercise 2.
Running a Java Program using Blue Jay.
Presentation transcript:

CS288 Lab Exercise 1

UniS Open PersonGui Files Go to Course web site for PersonGui source files Make copies of these files in you home folder and then open them in some editor (e.g. Emacs): PersonGui.java PersonMaker.java Person.java images.zip (unzip this file in the same directory as you have put the java files) Download a copy of these slides so that you can read them directly, and not simply view them in Internet Explorer. This is handy as you can then copy and paste code examples directly from these slides.

UniS Read the slides on compiling Java Code Make sure you have read the notes on compiling Java Code: Compile PersonGui.java. In a command window type: javac PersonGui.java now run the application java PersonGui Right click the mouse in the large text area. You should see a popup menu. Enter in your name age height etc with this menu. Right click the mouse and choose the create person item. If you have installed the images correctly from the zip file you should be able to choose a suitable image at this point.

UniS How the PersonGui should appear Choose this option should cause this dialog to appear

UniS How the PersonGui should appear Once you have picked an image it should then appear as below.

UniS 1: Search for Make_Person method Find (could use Search in Emacs) the Make_Person ( ) method in PersonMaker.java

UniS 1: Change the Make_Person method public String Make_Person ( ) { Show_Attributes_InFrame (); String return_value = "This Person has these attributes: \n " + "\n\tFirst Name \t= " + getFirstName() + "\n\tLast Name \t= " + getLastName() + "\n\tHeight \t= " + getPersonHeight() + "\n\tAge \t= " + getPersonAge() + "\n"; return return_value; } Change the value of Make_Person to this: Delete any.class files you have. Recompile and rerun the code. This should not make any difference to the way the code works. Test your code to make sure that is true.

UniS 1: Change the Make_Person method again public String Make_Person ( ) { Show_Attributes_InFrame (); String return_value = "This Person has these FANTASTIC attributes: \n " + "\n\tFirst Wonderful Name \t= " + getFirstName() + "\n\tLast Stunning Name \t= " + getLastName() + "\n\tLook at that Height \t= " + getPersonHeight() + "\n\tLook at that Age \t= " + getPersonAge() + "\n"; return return_value; } Change the value of Make_Person to this: Recompile and rerun the code. How does this change the way the code works?

UniS 1: Change the Make_Person method again public String Make_Person ( ) { Show_Attributes_InFrame (); String the_empty_string = ""; //This will be handy for the next part String return_value = "This Person has these FANTASTIC attributes: \n "; return_value = return_value + "\n\tFirst Wonderful Name \t= " + getFirstName(); return_value = return_value + "\n\tLast Stunning Name \t= " + getLastName(); return_value = return_value + "\n\tLook at that Height \t= " + getPersonHeight(); return_value = return_value + "\n\tLook at that Age \t= " + getPersonAge() + "\n"; return return_value; } Change the value of Make_Person to this: Recompile and rerun the code. How does this change the way the code works?

UniS 1: Set Empty String as Age If we set the first name to be empty with the menu:

UniS 1: Empty String as Age Then we get a somewhat redundant message on the screen

UniS 1: Look in PersonGui.java Change the Make_Person method so that if the user enters a value for Age that is the empty string, then the Make_Person returns a String that says: You entered an empty string for the first name Instead of The Persons First Name is: "" If the user enters a non-empty string the return value is unchanged. To do this you need to use an if statement. See the Java Tutorial on the course web site to see how if statements work: Go to the section on Learning the Java Language then to Language BasicsLearning the Java LanguageLanguage Basics then to Expressions, Statements, and BlocksExpressions, Statements, and Blocks Also you need to understand how some of the methods work for the String class. Go to the Java SDK 2, Class Specifications link on the course web site: dex.html

UniS Search for the String class in this column. Click on the String link

UniS Then click on the METHOD link at the top of the page. Now find the equals method for this class. This is useful if you want to know if a string is the empty string.

UniS 1: Change the Make_Person method again Now change the Make_Person method again so that if the User enters an empty string for the last name of someone a more sensible string is returned. Now change the method so that if a users age is greater than then the return_string makes a suitable comment about how incredibly old that person is.

UniS 2: Find PersonMaker Constructor Find the PersonMaker constructor in the PersonMaker.java file Find the reset_Person ( ) method.

UniS 2: PersonMaker Note the contents of reset_Person ( ) and PersonMaker ( ) are the same. Define a third method, public void set_default_values ( ) which is just a copy of the current reset_Person method with new name. Now change reset_Person ( ) and PersonMaker ( ) so that they simply call the set_default_values ( ) method and do not change any variable directly themselves.

UniS 3: Removing Redundant Labels Find the Person constructor method in the Person.java file

UniS 3: Removing Redundant Labels Person ( ) creates a seperate JLabel for height, age, first and last names. This is redundant. Change the code so that Person ( ) only uses one JLabel for all the strings that are to be displayed. The purpose of this exercise is for you to learn how to track all the data that is associated with one variable, and also modify that data for a different purpose.

UniS 3: Removing Redundant Labels For example in this case, you will have to work out where variables first_text last_text age_text height_text are referred to in the rest of the method. You will have to figure out how to combine these variables into a single string (new String variable declaration). You will have to comment out those parts of the code that set up and use unwanted JLabels (such as label_first). You will have to create a new JLabel for the combined text. Now attach the JLabel somehow so that it replaces the four redundant labels. You will be able to do this simply by copying the way the other JLabels are defined, you dont need to understand what it all means yet.