
----------------------------------------------------------
你说的新闻发布系统,在专业术语叫做CMS(内容管理系统),要做一个CMS可大可小,如果你只想做一个简单的,其实也不难,我不知道你做这个是为了什么。
如果你是只是为了应付毕业设计,实在不会的话,我劝你买本相关的书看看就够了、
如果给你详细的将,恐怕一天都讲不完,不知道你现在是什么水平。
如果你在学校一直用心学,做这个应该不难,实现简单的CMS系统,你至少要有一个表存放新闻数据,然后用程序实现增删改功能,设计一个显示新闻的WEB界面,如果再好点,可以增加一些管理功能,我只能给你所说简单的思想,具体技术还得你自己去学。
J2EE相关知识你要有所了解,像是JDBC更是必须熟练,Java基础更不用说了,其他的像是开发框架你可以不用。但是基本的东西必须掌握。
如果你是在没有思路,你还是买本相关的书籍看看吧,外面有很多,虽然质量不高,但是应付这种小系统没什么问题。
首先是主函数,其次是各个类函数,有三个类:News、Channel、ChannelManagment=========================================================
主函数:
#import "News.h"
#import "Channel.h"
#import "ChannelManagement.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
//新闻对象
News
*ne1 = [[News alloc]initWithTitle:@"kill" link:[NSURL
URLWithString:@"www.baidu.com"] description:@"a people killed another
one!"]
News *ne2 = [[News alloc]initWithTitle:@"number" link:[NSURL URLWithString:@"www.number.com"] description:@"this is a number!"]
News *ne3 = [[News alloc]initWithTitle:@"hello" link:[NSURL URLWithString:@"www.hello.com"] description:@"helloworld!"]
NSLog(@"%@",ne1)
//对新闻进行输出
NSLog(@"%@",ne2)
//频道对象
Channel *ch1 = [[Channel alloc]initWithSubject:@"NEWS" link:[NSURL URLWithString:@"www.imau.edu.cn"]]
//添加新闻到频道里
[ch1 addNews:ne1]
[ch1 addNews:ne2]
[ch1 addNews:ne3]
Channel *ch2 = [[Channel alloc]initWithSubject:@"READ" link:[NSURL URLWithString:@"www.read.cn"]]
[ch2 addNews:ne1]
[ch2 addNews:ne2]
Channel *ch3 = [[Channel alloc]initWithSubject:@"MUSIC" link:[NSURL URLWithString:@"www.music.cn"]]
[ch3 addNews:ne1]
[ch3 addNews:ne2]
//NSLog(@"%@",ch1)
//频道管理
ChannelManagement * chma = [[ChannelManagement alloc]initWithFileName:@"News.txt"]
//添加函数 字典中添加新闻和频道
[chma addNews:ne1 andChannel:ch1]
[chma addNews:ne2 andChannel:ch2]
[chma addNews:ne2 andChannel:ch3]
NSLog(@"%@",chma)
NSLog(@"channelCount : %lu",[chma channelCount])
NSInteger i = 1
//查找字典中指定元素
NSLog(@"channelAtIndex %ld : %@",i,[chma channelAtIndex:i])
//移除字典中指定元素
[chma removeChannels:i]
NSLog(@"%@",chma)
//移除频道下面的指定元素
[chma removeNews:i channel:ch2]
NSLog(@"%@",chma)
//查找频道下面指定的元素
NSLog(@"newsAtIndex %ld in channel %@ is: %@",i,@"ch2",[chma newsAtIndex:i channel:ch2])
//计算字典中频道下指定的元素
NSLog(@"channel %@ count is : %ld",@"cha2",[chma newCountAtChannel:ch2])
//保存函数 把字典中的成员写入文件
[chma write]
//还原函数 把字典中的成员读取出来
[chma read]
}
return 0
}
=========================================================
News.h文件:
#import@interface News : NSObject<NSCopying,NSCoding>
{
NSString * title //新闻标题
NSURL * link //新闻链接
NSString * description//新闻内容
}
@property(nonatomic,copy) NSString * title
@property(nonatomic,retain) NSURL * link
@property(nonatomic,copy)NSString * description
-(id)copyWithZone:(NSZone *)zone
//对数据成员进行初始化
-(id)initWithTitle:(NSString *)_title link:(NSURL *)_link description:(NSString *)_description
//打印函数,输出新闻的头、链接、内容
-(NSString *)description
@end
=========================================================
News.m 文件:
#import "News.h"
@implementation News
@synthesize title,link,description
-(id)copyWithZone:(NSZone *)zone
{
News * n = [[[self class]allocWithZone:zone]init]
[n setTitle:title]
[n setLink:link]
[n setDescription:description]
return n
}
//对数据成员进行初始化
-(id)initWithTitle:(NSString *)_title link:(NSURL *)_link description:(NSString *)_description
{
if (self = [super init]) {
title = _title
link = _link
description = _description
}
return self
}
//归档
-(void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:title forKey:@"TITLE"]
[aCoder encodeObject:link forKey:@"LINK"]
[aCoder encodeObject:description forKey:@"DESCRIPTION"]
}
//解档
-(id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super init]) {
title = [aDecoder decodeObjectForKey:@"TITLE"]
link = [aDecoder decodeObjectForKey:@"LINK"]
description = [aDecoder decodeObjectForKey:@"DESCRIPTION"]
}
return self
}
//打印函数,输出新闻的头、链接、内容
-(NSString *)description
{
NSString * str = [NSString stringWithFormat:@"News==>title:%@,link:%@,description:%@",title,link,description]
return str
}
@end
=========================================================
Chann.h 文件:
#import#import "News.h"
@interface Channel : NSObject<NSCopying,NSCoding>
{
NSString *subject //频道标题
NSURL *link //频道链接
NSMutableArray * arraylist //频道中新闻列表
}
@property(nonatomic,copy) NSString * subject
@property(nonatomic,retain) NSURL * link
@property(nonatomic,retain) NSMutableArray * arraylist
-(id)copyWithZone:(NSZone *)zone
//初始化数据成员
-(id)initWithSubject:(NSString *)_subject link:(NSURL *)_link
//添加新闻
-(void)addNews:(News *)_news
//移除指定的下标元素
-(void)removeNews:(NSInteger)index
//计算数组元素个数
-(NSInteger)newsCount
//打印函数 输出标题、链接、数组
-(NSString *)description
@end
=========================================================
Channel.m文件:
#import "Channel.h"
@implementation Channel
@synthesize subject,link,arraylist
-(id)copyWithZone:(NSZone *)zone
{
Channel *ch = [[[self class]allocWithZone:zone]init]
[ch setSubject:subject]
[ch setLink:link]
[ch setArraylist:arraylist]
return ch
}
//归档
-(void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:subject forKey:@"SUBJECT"]
[aCoder encodeObject:link forKey:@"LINK"]
[aCoder encodeObject:arraylist forKey:@"ARRAYLIST"]
}
//解档
-(id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super init]) {
subject = [aDecoder decodeObjectForKey:@"SUBJECT"]
link = [aDecoder decodeObjectForKey:@"LINK"]
arraylist = [aDecoder decodeObjectForKey:@"ARRAYLIST"]
}
return self
}
//初始化数据成员
-(id)initWithSubject:(NSString *)_subject link:(NSURL *) _link
{
if (self = [super init]) {
subject = _subject
link = _link
arraylist = [[NSMutableArray alloc] initWithCapacity:1]
}
return self
}
//添加新闻
-(void)addNews:(News *)_news
{
BOOL flag = YES
for (id objc in arraylist)
{
if (_news == objc)
{
NSLog(@"News exist!!")
flag = NO
}
}
if (flag)
{
[arraylist addObject:_news]
}
}
//移除指定的下标元素
-(void)removeNews:(NSInteger)index
{
[arraylist removeObjectAtIndex:index]
}
//计算数组元素个数
-(NSInteger)newsCount
{
return [arraylist count]
}
//打印函数 输出标题、链接、数组
-(NSString *)description
{
NSString *str = [NSString stringWithFormat:@"Subject:%@,Link:%@,Arraylist:%@",subject,link,arraylist]
return str
}
@end
=========================================================
ChannelManagement.h 文件:
#import#import "Channel.h"
@interface ChannelManagement : NSObject
{
NSMutableDictionary *channels//频道管理字典
NSString *filename //文件名
}
@property(nonatomic,retain) NSMutableDictionary *channels
@property(nonatomic,retain) NSString *filename
//始化数据成员
-(id)initWithFileName:(NSString *)_filename
//添加一个字典对象
-(void)addChannels:(NSDictionary *)_channel
//移除字典中指定下标的元素
-(void)removeChannels:(NSInteger)index
//查找字典中指定下标的元素
-(Channel*)channelAtIndex:(NSInteger)index
//计算字典里元素的个数
-(NSInteger)channelCount
//添加函数 字典中添加新闻和频道
-(void)addNews:(News *)_news andChannel:(Channel *)_channel
//移除频道下面的指定元素
-(void)removeNews:(NSInteger)index channel:(Channel *)_channel
//查找频道下面指定的元素
-(News*)newsAtIndex:(NSInteger)index channel:(Channel *)_channel
//计算字典中频道下指定的元素
-(NSInteger)newCountAtChannel: (Channel*)_channel
//保存函数 把字典中的成员写入文件
-(void) write
//还原函数 把字典中的成员读取出来
-(void) read
//打印函数 输出频道、存放数据的文件名
-(NSString *)description
@end
=========================================================
ChannelManagement.m 文件:
#import "ChannelManagement.h"
@implementation ChannelManagement
@synthesize channels,filename
//初始化数据成员
-(id)initWithFileName:(NSString *)_filename
{
if(self = [super init])
{
filename = _filename
channels = [[NSMutableDictionary alloc]initWithCapacity:2]
}
return self
}
//添加一个字典对象
-(void)addChannels:(NSDictionary *)_channel
{
// [channels setObject:_channel.subject forKey:@"channel.subject"]
// [channels setObject:_channel.link forKey:@"channel.link"]
// [channels setObject:_channel.arraylist forKey:@"channel.arraylist"]
[channels addEntriesFromDictionary:_channel]
}
//移除字典中指定下标的元素
-(void)removeChannels:(NSInteger)index
{
NSArray *array = [channels allKeys]
NSString *str = [array objectAtIndex:index]
[channels removeObjectForKey:str]
}
//查找字典中指定下标的元素
-(Channel*)channelAtIndex:(NSInteger)index
{
NSArray *array = [channels allKeys]
NSString *str = [array objectAtIndex:index]
Channel * ch = [channels objectForKey:str]
return ch
}
//计算字典里元素的个数
-(NSInteger)channelCount
{
return [channels count]
}
//添加函数 字典中添加新闻和频道
-(void)addNews:(News *)_news andChannel:(Channel *)_channel
{
// for (id objc in _channel.arraylist)
// {
// if (_news == objc)
// {
// NSLog(@"%@ have exist this news",_channel.subject)
// }
// }
[_channel addNews:_news]
NSString *sub = _channel.subject
[channels setObject:_channel forKey:sub]
}
//移除频道下面的指定元素
-(void)removeNews:(NSInteger)index channel:(Channel *)_channel
{
[_channel.arraylist removeObjectAtIndex:index]
}
//查找频道下面指定的元素
-(News*)newsAtIndex:(NSInteger)index channel:(Channel *)_channel
{
News *ne = [_channel.arraylist objectAtIndex:index]
return ne
}
//计算字典中频道下指定的元素
-(NSInteger)newCountAtChannel: (Channel*)_channel
{
NSInteger count = [_channel.arraylist count]
return count
}
//保存函数 把字典中的成员写入文件
-(void)write
{
BOOL result = [NSKeyedArchiver archiveRootObject:channels toFile:filename]
if (result)
{
NSLog(@"write success!")
}
else
{
NSLog(@"write fail!")
}
}
//还原函数 把字典中的成员读取出来
-(void)read
{
NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithFile:filename]
NSString *str = [NSString stringWithFormat:@"%@",array]
//NSLog(@"Content of %@ is : %@",filename,array)
NSLog(@"%@",str)
}
//打印函数 输出频道、存放数据的文件名
-(NSString *)description
{
NSLog(@"**************************频道管理***************************")
NSString *str = [NSString stringWithFormat:@"filename:%@",filename]
NSLog(@"***********************************************************")
NSArray *array = [channels allKeys]
for (id element in array ) {
NSLog(@"CHANNEL:%@ = %@",element,[channels objectForKey:element])
}
return str
}
@end
======================================
【●】你好【●】
.
按你描述,电脑中招的可能性很大,
.
【修复建议】:
.
首先使用可靠杀软全面查杀病毒木马,
卸载掉新近安装的软件和游戏等程序.
优化系统,取消勾选可疑的第三方开机自启动项
检查系统服务项,.停止+禁用非必须的第三方系统服务项.
☆要修复这种情况.你可尝试重启开机按F8键.进安全模式设置系统干净启动:
a).点击开始菜单并在搜索框中输入msconfig,然后按回车键。
b).点击“服务”标签卡,选择“隐藏所有的微软服务”.然后点击全部禁用.
c).点击“启动”标签卡, 然后点击全部禁用并确定。
然后重新启动计算机。当d出“系统配置实用程序”的时候,选中此对话框中的“不再显示这条信息”并点击确定。
提示: 临时禁用启动项只是为了预防启动加载时遇到的问题。此 *** 作不会影响系统或者其他程序,以后我们可以以手动启动的方式来启动这些程序。
纠正错误后,再从干净启动状态回复到正常启动模式:
a).点击开始菜单并在搜索框中输入msconfig,然后按回车键。
b).在“常规”选项卡上,单击“正常启动 - 加载所有设备驱动程序和服务”。
c).单击“确定”。当提示您重新启动计算机时,单击“重新启动”。
☆具体设置和执行系统干净启动的方法参见: http://support.microsoft.com/kb/331796/zh-cn
http://answers.microsoft.com/zh-hans/windows/forum/windows_vista-performance/answers/424b4486-464c-4169-979c-db4d80f6abab
d).你也可以尝试在安全模式里进行系统修复或系统还原.
.如果安全模式进不去或者进安全模式也还是会蓝屏.杯具,系统已彻底挂掉了.无法再修复系统.需要你在排除硬件故障后.使用系统备份恢复系统.没有系统备份.就只能彻底重装 *** 作系统.
18.祝你好运~
.
如果我的解答对解决你の问题有帮助.请点击我的回答下方【选为满意答案】按钮..
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)