Please follow me here!

Friday, May 31, 2013

JAVA Program: Command-based String Remover in Text Files

Hello, everyone.

Let me share with you the code on one of the programs I did back in March 2013, while doing my Data Structures class. This is a command-based program where what you do is enter what string you want to remove from a text file, than which text file you want to modify and return its result.

There is some documentation at the top of the code so that way you guys can understand how this works. The modified text file is always saved as ResultFile.txt.

The way on how to run it perfectly is to go onto the Microsoft Command Prompt, go to the directory where the class file is held, making sure all of the JAVA resources are there, then type in the following:

java Chapter14Exercise11 abc HelloThere.txt

"abc" is the string to be removed from the text file "HelloThere.txt."

/*
 *     Data Structures and Object-Oriented Programming - Assignment 6
 *     Question 14.11 of Introduction to Java Programming (by Daniel Liang)
 *
 *     Text Remover (Command Prompt fashion)
 *
 *     This program opens up an existing file and removes a string, both
 *     specified through the console that originally calls and executes
 *     the program. The resulting file is ResultFile.txt; if the Scanner
 *     object and the PrintWriter object refer to the same File object,
 *     the result will be a full blank file with zero bytes stored in memory.
 *
 *     Programmed by Gregory Desrosiers
 *
 *     Start Date: March 10, 2013
 *     End Date: March 10, 2013
 *
 *     File Name: Chapter14Exercise11.java
 *     Teacher: Amin Ranj Bar
 *
 *     *NOTE*: All strings to be removed, including single characters, are
 *     case-sensitive.
 *
 *     Small Change made on March 13, 2013: The "throws IOException" clause after the
 *     brackets in the header of the main has been removed because IOException is a
 *     subclass of Exception and is being handled by the try-catch-finally block.
 *
 */

import java.util.Scanner;
import java.io.*;

public class Chapter14Exercise11
{
    public static void main(String[] args)
    {
        boolean programComplete = false;
      
        Scanner fileReader = null;
        PrintWriter fileWriter = null;
      
        if(args.length == 0)
        {
            System.out.print("You have not specified what string to remove in the file and what file to access.\n\n" +
                    "Please execute program with the desired associate commands.");
            quit();
        }
        else if (args.length == 1)
        {
            System.out.print("What file do you want the program to access and remove the string?\nYou have not specified the file.\n\nPlease enter file name.");
            quit();
        }
        else if (args.length == 2 && !args[1].contains("."))
        {
            System.out.print("The file you specified does not contain a period. You need to enter the file extension.\n\n");
            quit();
        }
      
        try
        {
      
            fileReader = new Scanner(new File(args[1]));
            fileWriter = new PrintWriter(new File("ResultFile.txt"));
      
            while(fileReader.hasNext())
            {
                String currentLine = fileReader.nextLine();
          
                fileWriter.println(currentLine.replaceAll(args[0], ""));
            }
          
            System.out.print("File Operation complete. ");
            programComplete = true;
        }
        catch (Exception error)
        {
            if (error instanceof FileNotFoundException)
                System.err.println("Sorry! The file has not been found.");
            else if (error instanceof IOException)
                System.err.println("Something went wrong with either writing or reading the " +
                        "specified files. Needs to close.");
          
            // Debugging purpose only
            else if (error instanceof ClassNotFoundException)
            {
                System.err.println("Required classes have not been found.");
                error.printStackTrace();
            }
        }
        finally
        {
            if (fileReader != null)
                fileReader.close();
          
            if (fileWriter != null)
                fileWriter.close();
          
            if (programComplete)
                System.out.println("Program complete.");
        }
    }
  
    public static void quit()
    {
        System.out.println("Program terminated.");
        System.exit(1);
    }
}


That does it for this code! Have a nice night!

Arcade Games to check out

Hello, everyone.

How you people doing? I'm okay, though I am feeling mightily frustrated and lazy to try to work on a lot of things before my e-book, The Asperger Computer, can really sell out and make some more extra money besides getting a job this summer.

Anyway, I want to have a talk with you guys about computer games that you go to one setting and they only give you one little hint of fun; arcade games. Unless you happen to be an enthusiast of the 1980s golden era of computer games, or simply want to come back to 95's electronics, you might not have that much fun with arcades today as was before; then again, that's only me. However, I do get excited whenever I haven't played them in a long time.

So, what games I have played back in the past?

Sega Rally Championship
Time Crisis II
Zero Point by Unico
Virtua Racing
Final Lap 2
Final Lap 3
eXtreme Racing (Gaelco)
ATV Track (on Amazon)
Time Crisis 4
Daytona USA 2
Manx TT Superbike
Lucky & Wild
Cruis'n USA
Cruis'n Exotica
Outrunners
Outrun 2 SP
Motor Raid
Bowlingo
Club Kart European Version
Midway's CART Fury
Arctic Thunder
Hydro Thunder
San Francisco Rush 2049
Tokyo Cop
Radikal Bikers
Top Skater
Downhill Bikers (Namco)
Harley-Davidson Motorcycles
Airline Pilots (SEGA)
Sega Strike Fighter
18 Wheeler - American Pro Truck
F355 Challenge
Sega Super GT
The King of Route 66
Crazy Taxi
The Ocean Hunter
Jambo Safari
Battle Gear 3
Initial D: Arcade Stage
The House of The Dead
Air Trix
Nascar Racing
Star Wars Racer Arcade
Confidential Mission
Derby Owners Club
Aqua Jet (Namco)
Alpine Racer
Ridge Racer 2
FIM World Championships 500 GP (Namco)
Crisis Zone
Need for Speed Underground
Ace Driver: Victory Lap

So, what do you think about playing a whole bunch of games risen from the golden years and modern years like right now? Do you expect to endure yourself to extreme fun like this, or do you simply want to get away from important stuff and want to stick with what you love?

Anyway, there are more arcade games you can play than just those I'm mentioning. All you have to do is find an arcade vendor closest to your home, go there, and play the games they are offered. Take some money with you and spend the amount of time that money and those arcades give you to stimulate your brain and enjoy your perspective inside.

So, tell me, is there any arcade games you would absolutely want to play and spend all of your money, just t finish it? If you do, which ones are they? Why don't I talk about my answer first before you comment and tell me what you think of them?

I want to play Time Crisis II; ooh, it's such a great and fun game to play, regardless if it's short. But I think that's now Namco handles its business! What you have to do is, using the same strategy as the original Time Crisis, take down those enemies to advance to the next area. You have a pistol with a nine-bullet clip to fire from, and using a light gun, you are to shoot down soldiers of Neodyne Industries, an executive company run by Ernesto Diaz to conduct an evil intention.

After Diaz successfully launched 64 satellites into orbit, his next intention is to launch a nuclear satellite into space. We think he was to complete the Starline Network and unite the world, when after a couple of sentences from both Keith Martin and Robert Baxter, we find that what Diaz wants to do is pollute the planet with exhaust fumes and radioactive dust.

This is my assumption because it's not told in the game, sadly.

Anyway, by detonating the nuclear satellite in orbit, Diaz was to harm the entire planet with so much pollution that people will die from air toxins.

Because of this foil for ruling the planet and killing the people around Diaz, VSSE dispatches Keith and Robert to halt the launch and ruin Diaz's plans. Now, with their trusty Desert Eagles, the team must fight their way through nine different areas in three settings to eliminate Diaz and stop the countdown.

You can play the game with a friend, as Link Play, or just by yourself, as Solo Play. Companion-wise, you should play as two-player, because you two will be able to take out the enemies much more easily; it's a battle to see which one will earn the highest score or the highest accuracy. If you play two-player, you will be able to take out the bosses and some obstacles much more easily.

What else do I want to play? I think I'll play some of the original Midway arcade games, the newest games developed by Raw Thrills with Eugene Jarvis as the CEO, and some classical games like Galaga, Galaga '88, Xevious, Pacman, Donkey Kong, Mortal Kombat 1 and 4, some SNK games, as well as some new ones or old ones I haven't played yet.

Golden-based arcades and those made before 1989 are absolutely fun because if you are a pixel lover, you will definitely see the real rasterization of graphics at that time. It is truly binary - 0s and 1s. Everything was small, the colors were small, and the pixel detail was small.

Anyway, that does it for this blog. Hope to see you guys again next time!

Thursday, May 30, 2013

JAVA Program: Random 0s and 1s Table with Refresh Button

Hello, everyone. Got a new program I want to share with you guys that demonstrates the power of listening to an interactive button.

This program is a stand-alone GUI program where what you see is a 10 by 10 table of 0s and 1s, with a clickable "Refresh" button at the bottom. If you click on it, it randomizes all the values in the tables, changing them to 0s or 1s.

I'm going to share you the code that unless you read the explanations at the bottom, you can figure out for yourselves on how this actually works. There's a description at the top of the writing for your own convenience. Enjoy!


/*
 * Data Structures and Object-Oriented Programming - Assignment 7
 * Question 16.40 of Introduction to Java Programming (by Daniel Liang)
 * 
 *      Display Random 0 or 1 with Refresh Button
 *  
 *      Same mechanics as Question 12.14, except that a refresh button is included at
 *      the bottom of the window, and every time it is clicked, a new 10 by 10
 *      table of randomized 0s and 1s appear. 
 *  
 *      To accomplish this, the actionPerformed method for the refresh button executes 
 *      a loop that invokes the setText method for all the elements in the JLabel array, 
 *      and passes the string value of the value returned by a java.util.Random object's 
 *      nextInt method.
 * 
 * Programmed by Gregory Desrosiers
 * 
 * Start Date: March 23, 2013
 * End Date: March 23, 2013
 * 
 * File Name: Chapter16Exercise40.java
 * Teacher: Amin Ranj Bar
 * 
 * SPECIAL: The ActionListener for the Refresh button is an anoymonous inner class.
 */

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import java.awt.*;
import java.awt.event.*;
import java.util.Random;

public class Chapter16Exercise40 extends JFrame
{
private static final long serialVersionUID = -4480542370452207354L;

private JPanel mainPanel;

// Top Panel Components
private JPanel topPanel;
private JLabel[] labels;

// Bottom Panel Components
private JPanel bottomPanel;
private JButton refreshButton;

public static void main(String[] args)
{
Chapter16Exercise40 frame = new Chapter16Exercise40();

frame.setTitle("Exercise16_40");
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);

frame.pack();
frame.setVisible(true);
}

public Chapter16Exercise40()
{
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());

// Top Panel Construction

topPanel = new JPanel();
topPanel.setLayout(new GridLayout(10, 10, 16, 2));
topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
topPanel.setBackground(Color.BLUE);

Random binaryGenerator = new Random();
labels = new JLabel[100];

for (int x = 0; x < labels.length; x++)
{
labels[x] = new JLabel(String.valueOf(binaryGenerator.nextInt(2)));
labels[x].setHorizontalTextPosition(AbstractButton.CENTER);
labels[x].setForeground(Color.WHITE);
labels[x].setFont(new Font("Times New Roman", Font.PLAIN, 12));

topPanel.add(labels[x]);
}

mainPanel.add(topPanel, BorderLayout.NORTH);

// Bottom Panel Construction

bottomPanel = new JPanel();
bottomPanel.setBackground(Color.BLACK);

refreshButton = new JButton("Refresh");
refreshButton.setBackground(Color.WHITE);
refreshButton.setForeground(Color.BLACK);
refreshButton.setFont(new Font("Calibri", Font.BOLD, 12));

refreshButton.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e)
{
for (int y = 0; y < labels.length; y++)
labels[y].setText(String.valueOf(new         
                                                          Random().nextInt(2)));
}
});

bottomPanel.add(refreshButton);
mainPanel.add(bottomPanel, BorderLayout.CENTER);

add(mainPanel);
}
}
If you guys have any questions, comments, or suggestions, please post them right here! I am willing to accept them! Anyway, please follow me on Facebook, Twitter, and Google+! Facebook: https://www.facebook.com/pages/Gregory-Desrosiers/171954446270382 Twitter: http://www.twitter.com/GregoryDes

JAVA Program: Object-Oriented Programming Class, the PopMusicClass

Hello, everyone.

I want to share with you something new out of my knowledge of JAVA Programming; a fresh, original class I've designed where everything's quite simple, but is new to people who are yet unaware of the object-oriented programming approach.

Basically, the purpose of this approach is to create programs and methods that can be reused by any other programs developed in the same programming language. In fact, this approach was done to design the original JAVA classes that most JAVA programmers experience every time we write something. String, Short, Integer, File, Exception, Scanner, JLabel; all of the net classes that exist in today's versions of JAVA SDKs.

Here, what I have designed here is a class called PopMusicClass where it is designed to hold data of pop culture songs, especially those made today. It's not Beethoven or Scott Joplin's music. It's rather the music that we are making today.

I'll show you the code first, then tell you what it consists of.


public final class PopMusicClass
{
private String nameOfSong;
private String artist;
private String nameOfAlbum;

private short yearOfRelease;
private String releaseDate;

private String recordingStudio;
private String mixingStudio;

private String writers;
private String publishingRecord;
private String distributionStudio;

private String format;

public static void main(String[] args) // Testing only
{
PopMusicClass object1 = new PopMusicClass();
PopMusicClass object2 = new PopMusicClass("Firework", "Katy Perry", "Teenage Dream", (short)2010, "October 26, 2010",
"Roc the Mic Studios", "Roc the Mic", "Perry, Mikkel S. Eriksen, Tor Erik Hermansen, Sandy Wilhelm, Ester Dean",
"Capitol Records", "N/A", "CD, Downloadable form");

System.out.println(object1 + "\n\n" +  object2);
}

public PopMusicClass()
{
nameOfSong = null;
artist = null;
nameOfAlbum = null;

yearOfRelease = 1930;
releaseDate = null;

recordingStudio = null;
mixingStudio = null;

writers = null;
publishingRecord = null;
distributionStudio = null;
format = null;
}

public PopMusicClass(String nameOfSong, String artist, String nameOfAlbum, short yearOfRelease, String releaseDate, 
String recordingStudio, String mixingStudio, String writers, String publishingRecord, String distributionStudio,
String format)
{
this.nameOfSong = nameOfSong;
this.artist = artist;
this.nameOfAlbum = nameOfAlbum;

this.yearOfRelease = yearOfRelease;
this.releaseDate = releaseDate;

this.recordingStudio = recordingStudio;
this.mixingStudio = mixingStudio;

this.writers = writers;
this.publishingRecord = publishingRecord;
this.distributionStudio = distributionStudio;
this.format = format;
}

public void setNameOfSong(String nameOfSong)
{
this.nameOfSong = nameOfSong;
}

public void setArtist(String artist)
{
this.artist = artist;
}

public void setNameOfAlbum(String nameOfAlbum)
{
this.nameOfAlbum = nameOfAlbum;
}

public void setYearOfRelease(short yearOfRelease)
{
this.yearOfRelease = yearOfRelease;
}

public void setReleaseDate(String releaseDate)
{
this.releaseDate = releaseDate;
}

public void setRecordingStudio(String recordingStudio)
{
this.recordingStudio = recordingStudio;
}

public void setMixingStudio(String mixingStudio)
{
this.mixingStudio = mixingStudio;
}

public void setWriters(String writers)
{
this.writers = writers;
}

public void setPublishingRecord(String publishingRecord)
{
this.publishingRecord = publishingRecord;
}

public void setDistributionStudio(String distributionStudio)
{
this.distributionStudio = distributionStudio;
}

public void setFormat(String format)
{
this.format = format;
}

public String getNameOfSong()
{
return nameOfSong;
}

public String getArtist()
{
return artist;
}

public String getNameOfAlbum()
{
return nameOfAlbum;
}

public short getYearOfRelease()
{
return yearOfRelease;
}

public String getReleaseDate()
{
return releaseDate;
}

public String getRecordingStudio()
{
return recordingStudio;
}

public String getMixingStudio()
{
return mixingStudio;
}

public String getWriters()
{
return writers;
}

public String getPublishingRecord()
{
return publishingRecord;
}

public String getDistributionStudio()
{
return distributionStudio;
}

public String getFormat()
{
return format;
}

public boolean equals(Object o)
{
if (o instanceof PopMusicClass)
{
PopMusicClass object = ((PopMusicClass)o);

return this.nameOfSong.equals(object.nameOfSong) && this.artist.equals(object.artist) &&
this.nameOfAlbum.equals(object.nameOfAlbum) && this.yearOfRelease == object.yearOfRelease &&
this.releaseDate.equals(object.releaseDate) && this.recordingStudio.equals(object.recordingStudio) &&
this.mixingStudio.equals(object.mixingStudio) && this.writers.equals(object.writers) &&
this.publishingRecord.equals(object.publishingRecord) && 
this.distributionStudio.equals(object.distributionStudio) &&
this.format.equals(object.format);
}
else
return false;
}

public String toString()
{
return nameOfSong + "\nArtist: " + artist + "\n\nName of Album: " + nameOfAlbum + "\n\nYear of Release: " + yearOfRelease + 
"\nRelease Date: " + releaseDate + "\n\nRecording Studio: " + recordingStudio + "\nMixing Studio: " + mixingStudio + 
"\nWriters: " + writers + "\n\nPublishing Record: " + publishingRecord + "\n\nDistribution Studio: " + distributionStudio +
"\nFormat: " + format;
}
}

The program consists of  11 fields, two constructors, 11 set methods, 11 get methods, and two methods that override those with the same name and signature from the Object class: equals and toString. Oh, and the final modifier in the header of the class definition is to tell the compiler that this class cannot be inherited.

The main method you see at the top of the code is to test with constructing and displaying them on the console. The other methods were not tested for validation.

For those of you who don't know what Object-Oriented Programming is, it's simply a term to describe reusable programs and data structures that the only way you can modify data and prevent so many bugs happening in your program is to call in the class methods defined in the object you create. This is to prevent accidental corruption that can bug your programs and cause multiple problems.

How it works is that the data that each object carries is encapsulated in such a way that the user has no way of gaining access to that data directly; the only way to access it is indirectly through the methods that operate on it. That's why the data fields are declared with the access specifier "private." When it comes time to program something else other than this class, it's important to ensure that we do not actually call in one of the object's fields and assign it with a new value or reference to an object.

As for the methods, because the user or programmer is able to call in those methods in a different program, they are declared with either "default", "protected:, or even "public" access modifier.

Anyway, I apologize to say, but I'm kind of lazy to keep on talking about this. I think I'll leave other explanations for another time, so I'll see you later!

Ciao!

Wednesday, May 29, 2013

Announcement on "The Asperger Computer"

Hello, everyone. This is a quick message to everyone who reads my blogs.

The e-book I'm selling, The Asperger Computer, will be going through a large editing procedure so that way I can reach out more buyers and fix up my marketing problems.

No one is buying my e-book and many people who are looking at my publicity are thinking that what's in the book is not worth buying it, especially when the book lacks a lot of information about Asperger's syndrome. I need to add more content on that to be able for others to check out and get a full picture of what I'm talking about. There's also the problem where I have shared my television interview to a Facebook group called "Asperger's Syndrome" with over 11,000 members, and this started to affect my reputation negatively because they found a lot of mistakes in my interview that I am now to fix.

So, in addition to editing a lot in my e-book, I am going to be in touch with the original reporter at Global saying that sadly, some users from a group are really disagreeing on my interview and that it is turning me down so bad I'll need to consider doing another television interview to fix things up; not through Global, but by other news outlets such as CBC.

I will plan on keeping my text as original and the same as possible from my original edition, so you shouldn't see that much loss from what I've been doing. in addition, you will get to see new content I previously had in mind to write it down but not actually work on it.

If you guys have any questions or comments as I work, please let me know!

Anyway, have a good night!

Tuesday, May 28, 2013

JAVA Program : Hello World!

I want to share with you guys a simple program to demonstrate what software programming is about; this is a "Hello World!" example that many people see when learning on how to write computer programs using a specific programming language.

In this case, I'm going to show you on how to create the example program in JAVA. If you do not have JAVA installed, be sure to go on to http://www.oracle.com and download the latest version of the language plugin on your computer. You should also take the time to download a developer's toolkit and an integrated development environment for you to write programs at a more convenient level.

The advantage of using an IDE over a text file is, every time you save your source code file, it is compiled automatically. You can also see the moment you make a mistake, a compiler error seen on the scroll bar where if you hover your mouse over, you'll see why you get an error like this.

Read the on-screen instructions and check to see if you have enough space on your computer or hard drive to install the software needed. By the time you have it installed, open up the IDE and follow the introduction instructions and how to go to the workspace and write a new source code file.

When you get there, you should see a large white text area with the cursor on the top left corner, with no characters inserted. That's where you will start writing your source code.

Let's get started, shall we?



The first thing you need to do is declare and open up a class definition. This is where your program is going to lie; the other purpose of a class definition is to prepare "a recipe where you can make exact copies of it," which is essentially the principle of object-oriented programming. But let's worry about making a simple program for now.

Type in "public class," all in lower case, and then the class name. You want to make sure that the class name is the same as the file name you're typing in, without the .java extension, because otherwise you will receive a compiler error. You cannot declare a class name that is other than the name of the source code file itself.

Since we have created a file called "HelloWorld.java," the header of the definition will look like this:
public class HelloWorld

Next, press Enter, and type in the left brace, press Enter, and the right brace. This is where you should be so far:

public class HelloWorld
{
}

Now, you want to add an empty bar between the braces, because you're now going to add a method called "main." This is what the code should look like by now:

public class HelloWorld
{

}

The "main" method is always the first method the program goes to upon execution. This is where your starting statements or your method calls will be done. The header is usually constant, but you'll eventually see that the parentheses can be set up in different ways as long as you can declare it of the same type.

Anyway, the header of the main method looks like this:

public static void main(String[] args)

If you are curious about what each part of the header is, let me tell you what they are.

"public" is an access specifier. It tells the compiler how the method can be accessed. There are two other specifiers you can use, with an extra one being no specifier at all; each one of them has a different visiblity, so you may want to stick with the specifier "public" before learning on how the other specifiers set the access to a method or a class. The other specifiers you can use for a method or class are "private" and "protected"; do not use them in your class declaration, however. You can only use them in what are called inner classes, which you shall see later if you decide to keep learning.

"static" simply means it is part of the entire class and not to every specific object. Let's say you instantiate 10 objects out of the Car class you've programmed yourself beforehand, and you declared a counter in the class with the word "static" that every time you instantiate the class for an object, it increases by one. Instead of returning 1 when you want to display that variable, because it is common to all objects, it returns 10.

You cannot reference a static variable or method with a non-static variable or method; otherwise you will get a compiler error. All Java classes use main as part of the entire class instead of every single object instantiated, so that's why the method is declared as a static method.

"void" is a return type. All method headers you write need to have their return types declared, but since the main is not designed to return anything, we use the key word "void." For any primitive data type or object type, you have to specifically return a reference or an actual value, as dependent on the type. If you attempt to return something in a void method, you will get a compiler error.

"main" is simply the name of the method. All methods and classes have names associated with their declaration; it's the norm for programming applications or experiments.

And what's inside the brackets are simply the arguments of the method. In this case, we are declaring one argument to be an array of String objects. You'll see more information about this by still attending your programming course or even reading a book on doing programming like this,

Anyway, moving on to the programming, what you want to do next is the same thing you did as the step after declaring your class: add two opposing braces, with an empty line, over three different lines. It will look like this:

public static void main(String[] args)
{

}

This program consists of displaying a simple message, so what we want to do is use console output. In Java, the way to do this is to use a method called println, referenced by System.out. The statement looks like this:

System.out.println();

Any object reference, variable, or a constant string message, can go between the parentheses and be displayed on the console upon execution. Here, we want to display a message, so we write the statement like this: 

System.out.println("Hello world!");

Put the statement inside the braces of the main method. The final program will look like this:

public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello world!");
}
}

Compile your program using the IDE compiler or the command way, run your program on the command prompt, or IDE, and voila: you will see "Hello world!" on your screen!

That's how you write the most simplest Java program; if you keep paying attention to every specific detail of the program, you'll eventually build your steps to becoming a programmer.

Anyway, I'll see you around!

Introducing myself (original blog on Autism Support Network)

This is a message opening up a topic on the Autism Support Network where the original message was uploaded there minutes before this one (May 28th, 2013).

Enjoy reading!


Hello, everyone. Let me introduce myself.

I am an English college student from Montreal, Canada, with the goal of being part of the network to grow awareness on me and eventually share my e-book, because currently no one seems to buy it, and so this is where I'll build part of the recognition and reputation needed to reach my goals.

As you have seen already in my profile summary, I am taking courses in Computer Science and Mathematics with the biggest educational interest in learning on how to program and eventually make way to create my own computer games in my career. As of right now, I have gained knowledge on how to write programs in JAVA, but I also want to learn on how to program in Visual Basic, C++, and even C. This is for me to get into the fundamentals of programming and demonstrate a low-to-moderate level of competency before I use today's tools for programming in today's games.

I am also an individual living with Asperger's syndrome and have been going through a lot of negative and intervened experiences. The most important issue I'm trying to resolve that I am attempting to pull out and cope with that's been going on for five years is being occasionally invited to be with friends and have a great time at the same rate as people without AS or any mental diagnosis. As for the past two years, I am also trying to get myself into the real world with the success of a very good profit and being able to do things I wasn't able to reach out yet from my childhood. This involves getting recognized, earning support and praise, and being able to do things that other people want to see me do: sing a song, deliver a speech, program an application for use, talk about what I'm smart in, make YouTube videos or anything multimedia; you name it.

Here's a project I've done that I tried to sell a lot last summer but failed to do so because I did not had a marketing budget. I even sacrificed the summer for this over getting a job because I had high expectations for me to pay off my expenses from the profit of my work alone.  They are up on YouTube shown here: http://www.youtube.com/playlist?list=PLEBEED5651A491170&feature=mh_lolz

Anyway, that's a fresh new beginning here. But I hope that in the long run, probably like in three weeks or so, things start to get really handy here.

Oh, and if you guys are curious about my e-book, check it out here: https://www.facebook.com/TheAspergerComputerGregDes 

Well, I'll see you guys around!


Please follow me on Facebook, Twitter and/or YouTube!

YouTube: http://www.youtube.com/user/Bammer2001 & the channel where my music videos were uploaded.

Please leave comments and follow me on The Autism Support Network!

Sunday, May 26, 2013

Demonstration of JAVA Classes

Hello, everyone. Gregory here; how you people doing? I've completed my fourth semester at my college and now taking the time to find a job and get working for money and earn a better living.

Anyway, there's something I want to share with you guys. This is a demonstration on how to write your own classes in JAVA you can then instantiate and use in your main program for any use that the object is designed for.

What I'm showing you is the code for a class I've written in January 2013 as a practice for me to get back to my knowledge in JAVA for my Data Structures class during the semester. It's called "ComputerGame"; all it does is it lets you create objects destined to hold information about computer games.

*NOTE*: The only thing that's missing in the code is the overridden equals method, originally from the Object class.

public class ComputerGame
{

       private String nameOfGame;
       private String gamePlatform;

       private String gameDeveloper;
       private String gamePublisher;
       private String gameDistributor;

       private short yearOfRelease;

       public static void main(String[] args)  // Testing purposes only
       {

              ComputerGame testObject = new ComputerGame("Super Mario Bros.", "Nintendo Entertainment System", "Nintendo R&D", "Nintendo of America, Inc.", "Nintendo of America, Inc.", (short)1985);

              System.out.println(testObject.toString() + "\n\n" + testObject.superToString() + "\n\nModifying Object...\n\n");

              testObject.setName("The Legend of Zelda: Ocarina of Time");
              testObject.setGamePlatform("Nintendo 64");
              testObject.setGameDeveloper("Nintendo EAD (produced and directed by Shigeru Miyamoto)");
              testObject.setGamePublisher("Nintendo of America, Inc.");
              testObject.setGameDistributor("Nintendo of America, Inc.");

              testObject.setYearOfRelease((short)1998);

              System.out.println(testObject.toString() + "\n\n" + testObject.superToString());

       }
      
       public ComputerGame()
       {
              nameOfGame = "";
              gamePlatform = "";
             
              gameDeveloper = "";
              gamePublisher = "";
              gameDistributor = "";

              yearOfRelease = 1972;

       }
      
       public ComputerGame(String gameName, String platformOfGame, String developer, String publisher, String distributor, short releaseYear)
       {
              nameOfGame = gameName;

              gamePlatform = platformOfGame;
             
              gameDeveloper = developer;
              gamePublisher = publisher;
              gameDistributor = distributor;
             
              yearOfRelease = releaseYear;

       }

       public void setName(String gameName)
       {
              nameOfGame = gameName;
       }

      

       public void setGamePlatform(String platformOfGame)
       {
              gamePlatform = platformOfGame;
       }

      

       public void setGameDeveloper(String developer)
       {
              gameDeveloper = developer;
       }

       public void setGamePublisher(String publisher)
       {
              gamePublisher = publisher;
       }
      
       public void setGameDistributor(String distributor)
       {
              gameDistributor = distributor;
       }

       public void setYearOfRelease(short releaseYear)
       {
              yearOfRelease = releaseYear;
       }
      
       public String getName()
       {
              return nameOfGame;
       }

      

       public String getGamePlatform()
       {
              return gamePlatform;
       }

       public String getGameDeveloper()
       {
              return gameDeveloper;
       }
      
       public String getGamePublisher()
       {
              return gamePublisher;
       }
      
       public String getGameDistributor()
       {
              return gameDistributor;
       }
      
       public short getYearOfRelease()
       {
              return yearOfRelease;
       }
      
       public String toString()
       {
              return "Name of Game : " + nameOfGame + "\nPlatform : " + gamePlatform + "\n\nDeveloper : " + gameDeveloper + "\nPublisher : " + gamePublisher + "\n\nDistributor : " + gameDistributor + "\n\nRelease Year : " + yearOfRelease;

       }

       public String superToString()
       {
              return super.toString();
       } 
}
 
The way on how this works is, in the main method, you call the constructor as you would for any object you create. When you use the set methods, pass the required value through the parentheses; upon execution, the field that the set method is designed for will be overwritten with the new value. As for the get method, calling them will return the desired property. The toString method overrides the method defined in the Object class, but a method called superToString will allow you to view the original string from the Object class.
 
Well, that's it for this blog. Have any questions or comments? Please be sure to follow me on Facebook and Twitter!

Google+ Followers

Popular Posts by Gregory